From daniel at zuster.org Mon Nov 9 00:08:28 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 06:08:28 -0000 Subject: [llvm-commits] [zorg] r86519 - /zorg/trunk/zorg/buildbot/builders/ClangBuilder.py Message-ID: <200911090608.nA968TpF010765@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 00:08:28 2009 New Revision: 86519 URL: http://llvm.org/viewvc/llvm-project?rev=86519&view=rev Log: Add some more options to the Clang build factory. Modified: zorg/trunk/zorg/buildbot/builders/ClangBuilder.py Modified: zorg/trunk/zorg/buildbot/builders/ClangBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/ClangBuilder.py?rev=86519&r1=86518&r2=86519&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/builders/ClangBuilder.py (original) +++ zorg/trunk/zorg/buildbot/builders/ClangBuilder.py Mon Nov 9 00:08:28 2009 @@ -11,7 +11,8 @@ from zorg.buildbot.commands.ClangTestCommand import ClangTestCommand from zorg.buildbot.commands.BatchFileDownload import BatchFileDownload -def getClangBuildFactory(triple, clean=True, test=True): +def getClangBuildFactory(triple=None, clean=True, test=True, + expensive_checks=False, run_cxx_tests=False, valgrind=False): f = buildbot.process.factory.BuildFactory() # Determine the build directory. @@ -30,13 +31,21 @@ mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', defaultBranch='trunk', workdir='llvm/tools/clang')) - f.addStep(Configure(command=['./configure', - '--build', triple, - '--host', triple, - '--target', triple], + + # Force without llvm-gcc so we don't run afoul of Frontend test failures. + configure_args = ["./configure", "--without-llvmgcc", "--without-llvmgxx"] + config_name = 'Debug' + if expensive_checks: + configure_args.append('--enable-expensive-checks') + config_name += '+Checks' + if triple: + configure_args += ['--build=%s' % triple, + '--host=%s' % triple, + '--target=%s' % triple] + f.addStep(Configure(command=configure_args, workdir='llvm', - description=['configuring','Debug'], - descriptionDone=['configure','Debug'])) + description=['configuring',config_name], + descriptionDone=['configure',config_name])) if clean: f.addStep(WarningCountingShellCommand(name="clean-llvm", command="make clean", @@ -50,6 +59,14 @@ description="compiling llvm & clang", descriptionDone="compile llvm & clang", workdir='llvm')) + clangTestArgs = '-v' + if valgrind: + clangTestArgs += ' --vg ' + clangTestArgs += ' --vg-arg --leak-check=no' + clangTestArgs += ' --vg-arg --suppressions=%(builddir)s/llvm/tools/clang/utils/valgrind/x86_64-pc-linux-gnu_gcc-4.3.3.supp' + extraTestDirs = '' + if run_cxx_tests: + extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests' if test: f.addStep(ClangTestCommand(name='test-llvm', command=["make", "check-lit", "VERBOSE=1"], @@ -57,7 +74,8 @@ descriptionDone=["test", "llvm"], workdir='llvm')) f.addStep(ClangTestCommand(name='test-clang', - command=WithProperties("nice -n 10 make test VERBOSE=1"), + command=['make', 'test', WithProperties('TESTARGS=%s' % clangTestArgs), + WithProperties('EXTRA_TESTDIRS=%s' % extraTestDirs)], workdir='llvm/tools/clang')) return f From daniel at zuster.org Mon Nov 9 00:08:36 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 06:08:36 -0000 Subject: [llvm-commits] [zorg] r86520 - /zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py Message-ID: <200911090608.nA968aCg010780@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 00:08:36 2009 New Revision: 86520 URL: http://llvm.org/viewvc/llvm-project?rev=86520&view=rev Log: Add an optional only_addresses regular expression, which can be used to filter the email lookups (non-matches will go to the default address). Modified: zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py Modified: zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py?rev=86520&r1=86519&r2=86520&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py (original) +++ zorg/trunk/zorg/buildbot/util/ConfigEmailLookup.py Mon Nov 9 00:08:36 2009 @@ -7,20 +7,35 @@ file to match commit authors to email addresses. """ + # FIXME: This should be able to reload the config file when it + # changes. + zope.interface.implements(buildbot.interfaces.IEmailLookup) - compare_attrs = ["author_filename", "default_address"] + compare_attrs = ["author_filename", "default_address", "only_addresses"] - def __init__(self, author_filename, default_address): + def __init__(self, author_filename, default_address, only_addresses = None): from ConfigParser import ConfigParser self.author_filename = author_filename self.default_address = default_address + self.only_addresses = only_addresses self.config_parser = ConfigParser() self.config_parser.read(author_filename) + if only_addresses: + import re + self.address_match_p = re.compile(only_addresses).match + else: + self.address_match_p = lambda addr: True + def getAddress(self, name): try: - return self.config_parser.get("authors", name) + email = self.config_parser.get("authors", name) except: return self.default_address + + if self.address_match_p(email): + return email + + return self.default_address From evan.cheng at apple.com Mon Nov 9 00:49:22 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Nov 2009 06:49:22 -0000 Subject: [llvm-commits] [llvm] r86521 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Message-ID: <200911090649.nA96nM21012250@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 9 00:49:22 2009 New Revision: 86521 URL: http://llvm.org/viewvc/llvm-project?rev=86521&view=rev Log: 80 col. Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=86521&r1=86520&r2=86521&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Mon Nov 9 00:49:22 2009 @@ -39,8 +39,10 @@ using namespace llvm; static cl::opt PreSplitLimit("pre-split-limit", cl::init(-1), cl::Hidden); -static cl::opt DeadSplitLimit("dead-split-limit", cl::init(-1), cl::Hidden); -static cl::opt RestoreFoldLimit("restore-fold-limit", cl::init(-1), cl::Hidden); +static cl::opt DeadSplitLimit("dead-split-limit", cl::init(-1), + cl::Hidden); +static cl::opt RestoreFoldLimit("restore-fold-limit", cl::init(-1), + cl::Hidden); STATISTIC(NumSplits, "Number of intervals split"); STATISTIC(NumRemats, "Number of intervals split by rematerialization"); From evan.cheng at apple.com Mon Nov 9 00:49:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Nov 2009 06:49:37 -0000 Subject: [llvm-commits] [llvm] r86522 - in /llvm/trunk/lib/CodeGen: LiveIntervalAnalysis.cpp SelectionDAG/SelectionDAGISel.cpp Message-ID: <200911090649.nA96nb8x012271@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 9 00:49:37 2009 New Revision: 86522 URL: http://llvm.org/viewvc/llvm-project?rev=86522&view=rev Log: Hide a couple of options. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=86522&r1=86521&r2=86522&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Nov 9 00:49:37 2009 @@ -53,7 +53,8 @@ static cl::opt EnableFastSpilling("fast-spill", cl::init(false), cl::Hidden); -static cl::opt EarlyCoalescing("early-coalescing", cl::init(false)); +static cl::opt EarlyCoalescing("early-coalescing", + cl::init(false), cl::Hidden); static cl::opt CoalescingLimit("early-coalescing-limit", cl::init(-1), cl::Hidden); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=86522&r1=86521&r2=86522&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Nov 9 00:49:37 2009 @@ -68,7 +68,7 @@ EnableFastISelAbort("fast-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \"fast\" instruction fails")); static cl::opt -SchedLiveInCopies("schedule-livein-copies", +SchedLiveInCopies("schedule-livein-copies", cl::Hidden, cl::desc("Schedule copies of livein registers"), cl::init(false)); From sabre at nondot.org Mon Nov 9 01:07:57 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 07:07:57 -0000 Subject: [llvm-commits] [llvm] r86524 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/intrinsics.ll Message-ID: <200911090707.nA977vA9012870@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 01:07:56 2009 New Revision: 86524 URL: http://llvm.org/viewvc/llvm-project?rev=86524&view=rev Log: if a 'with overflow' intrinsic just has the normal result used, simplify it to a normal binop. Patch by Alastair Lynn, testcase by me. Added: llvm/trunk/test/Transforms/InstCombine/intrinsics.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86524&r1=86523&r2=86524&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Nov 9 01:07:56 2009 @@ -12452,6 +12452,47 @@ return ExtractValueInst::Create(IV->getInsertedValueOperand(), exti, exte); } + if (IntrinsicInst *II = dyn_cast(Agg)) { + // We're extracting from an intrinsic, see if we're the only user, which + // allows us to simplify multiple result intrinsics to simpler things that + // just get one value.. + if (II->hasOneUse()) { + // Check if we're grabbing the overflow bit or the result of a 'with + // overflow' intrinsic. If it's the latter we can remove the intrinsic + // and replace it with a traditional binary instruction. + switch (II->getIntrinsicID()) { + case Intrinsic::uadd_with_overflow: + case Intrinsic::sadd_with_overflow: + if (*EV.idx_begin() == 0) { // Normal result. + Value *LHS = II->getOperand(1), *RHS = II->getOperand(2); + II->replaceAllUsesWith(UndefValue::get(II->getType())); + EraseInstFromFunction(*II); + return BinaryOperator::CreateAdd(LHS, RHS); + } + break; + case Intrinsic::usub_with_overflow: + case Intrinsic::ssub_with_overflow: + if (*EV.idx_begin() == 0) { // Normal result. + Value *LHS = II->getOperand(1), *RHS = II->getOperand(2); + II->replaceAllUsesWith(UndefValue::get(II->getType())); + EraseInstFromFunction(*II); + return BinaryOperator::CreateSub(LHS, RHS); + } + break; + case Intrinsic::umul_with_overflow: + case Intrinsic::smul_with_overflow: + if (*EV.idx_begin() == 0) { // Normal result. + Value *LHS = II->getOperand(1), *RHS = II->getOperand(2); + II->replaceAllUsesWith(UndefValue::get(II->getType())); + EraseInstFromFunction(*II); + return BinaryOperator::CreateMul(LHS, RHS); + } + break; + default: + break; + } + } + } // Can't simplify extracts from other values. Note that nested extracts are // already simplified implicitely by the above (extract ( extract (insert) ) // will be translated into extract ( insert ( extract ) ) first and then just Added: llvm/trunk/test/Transforms/InstCombine/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/intrinsics.ll?rev=86524&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/intrinsics.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/intrinsics.ll Mon Nov 9 01:07:56 2009 @@ -0,0 +1,12 @@ +; RUN: opt %s -instcombine -S | FileCheck %s + +declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8) + +define i8 @test1(i8 %A, i8 %B) { + %x = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %A, i8 %B) + %y = extractvalue {i8, i1} %x, 0 + ret i8 %y +; CHECK: @test1 +; CHECK-NEXT: %y = add i8 %A, %B +; CHECK-NEXT: ret i8 %y +} From clattner at apple.com Mon Nov 9 01:09:03 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 8 Nov 2009 23:09:03 -0800 Subject: [llvm-commits] Patch: simplification of overflow operations In-Reply-To: References: Message-ID: On Nov 6, 2009, at 11:52 PM, Alastair Lynn wrote: > Hello- > > The attached patch will simplify cases where overflow intrinsics are > used but the overflow bit is not to the equivalent basic > instructions (llvm.uadd.with.overflow => add, for instance). > > This is my first patch, please don't judge me too harshly! Thanks, applied in r86524 with some minor formatting changes, I also added a testcase: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091109/090673.html It would also be nice to simplify the case when just the overflow result is used (in cases where the overflow check is a single compare). Thanks for doing this! -Chris From sabre at nondot.org Mon Nov 9 01:12:01 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 07:12:01 -0000 Subject: [llvm-commits] [llvm] r86525 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 01:12:01 2009 New Revision: 86525 URL: http://llvm.org/viewvc/llvm-project?rev=86525&view=rev Log: make this handle redefinition of malloc with different prototype correctly. Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86525&r1=86524&r2=86525&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Nov 9 01:12:01 2009 @@ -568,8 +568,7 @@ const Type *VoidTy = Type::getVoidTy(M->getContext()); const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); // prototype free as "void free(void*)" - Function *FreeFunc = cast(M->getOrInsertFunction("free", VoidTy, - IntPtrTy, NULL)); + Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL); CallInst* Result = NULL; Value *PtrCast = Source; if (InsertBefore) { @@ -582,7 +581,8 @@ Result = CallInst::Create(FreeFunc, PtrCast, ""); } Result->setTailCall(); - Result->setCallingConv(FreeFunc->getCallingConv()); + if (Function *F = dyn_cast(FreeFunc)) + Result->setCallingConv(F->getCallingConv()); return Result; } From daniel at zuster.org Mon Nov 9 01:25:15 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 07:25:15 -0000 Subject: [llvm-commits] [zorg] r86526 - /zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py Message-ID: <200911090725.nA97PGF1013604@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 01:25:15 2009 New Revision: 86526 URL: http://llvm.org/viewvc/llvm-project?rev=86526&view=rev Log: Add plain LLVM build factory. Added: zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py Added: zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py?rev=86526&view=auto ============================================================================== --- zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py (added) +++ zorg/trunk/zorg/buildbot/builders/LLVMBuilder.py Mon Nov 9 01:25:15 2009 @@ -0,0 +1,64 @@ +import os + +import buildbot +import buildbot.process.factory +from buildbot.steps.source import SVN +from buildbot.steps.shell import Configure, ShellCommand +from buildbot.steps.shell import WarningCountingShellCommand +from buildbot.process.properties import WithProperties + +from zorg.buildbot.commands.ClangTestCommand import ClangTestCommand + +def getLLVMBuildFactory(triple=None, clean=True, test=True, + expensive_checks=False, + jobs=1, timeout=20): + f = buildbot.process.factory.BuildFactory() + + # Determine the build directory. + f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir", + command=["pwd"], + property="builddir", + description="set build dir", + workdir=".")) + + # Checkout sources. + f.addStep(SVN(name='svn-llvm', + mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', + defaultBranch='trunk', + workdir='llvm')) + + # Force without llvm-gcc so we don't run afoul of Frontend test failures. + configure_args = ["./configure", "--without-llvmgcc", "--without-llvmgxx"] + config_name = 'Debug' + if expensive_checks: + configure_args.append('--enable-expensive-checks') + config_name += '+Checks' + if triple: + configure_args += ['--build=%s' % triple, + '--host=%s' % triple, + '--target=%s' % triple] + f.addStep(Configure(command=configure_args, + workdir='llvm', + description=['configuring',config_name], + descriptionDone=['configure',config_name])) + if clean: + f.addStep(WarningCountingShellCommand(name="clean-llvm", + command="make clean", + haltOnFailure=True, + description="cleaning llvm", + descriptionDone="clean llvm", + workdir='llvm')) + f.addStep(WarningCountingShellCommand(name="compile", + command=WithProperties("nice -n 10 make -j%s" % jobs), + haltOnFailure=True, + description="compiling llvm", + descriptionDone="compile llvm", + workdir='llvm', + timeout=timeout*60)) + if test: + f.addStep(ClangTestCommand(name='test-llvm', + command=["make", "check-lit", "VERBOSE=1"], + description=["testing", "llvm"], + descriptionDone=["test", "llvm"], + workdir='llvm')) + return f From baldrick at free.fr Mon Nov 9 01:35:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 08:35:58 +0100 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> Message-ID: <4AF7C65E.4020107@free.fr> Hi Kenneth, > If a struct can't be returned in registers, have SelectionDAGBuild > insert a hidden sret parameter ... in general changing a struct returning function to use sret instead alters the calling convention, so could break ABI conformance. Presumably that's ok here because the ABI doesn't specify how to return structs that require so many registers anyway? Ciao, Duncan. From vargaz at gmail.com Mon Nov 9 01:39:38 2009 From: vargaz at gmail.com (Zoltan Varga) Date: Mon, 9 Nov 2009 08:39:38 +0100 Subject: [llvm-commits] [PATH] Implement generation of dwarf unwind info on ARM ELF Message-ID: <295e750a0911082339p3428e9m3529e903f0bccf4e@mail.gmail.com> Hi, The attached patch implements the generation of DWARF unwind info on ARM. It is currently only enabled on ELF platforms when -unwind-tables is passed to llc. I tested with manually by examining the output of objdump -W. Please review and commit if it looks ok. Zoltan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/b5e017e2/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-arm-unwind.diff Type: text/x-diff Size: 8224 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/b5e017e2/attachment.bin From daniel at zuster.org Mon Nov 9 02:07:40 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 08:07:40 -0000 Subject: [llvm-commits] [zorg] r86530 - /zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Message-ID: <200911090807.nA987eVb015474@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 02:07:40 2009 New Revision: 86530 URL: http://llvm.org/viewvc/llvm-project?rev=86530&view=rev Log: Parameterize LLVM stage 1 and 2 build configs. Also, switch to Release as the default for both stage 1 and stage 2. A stage 2 LLVM Release build is *really* slow if the llvm-gcc was built with a Debug LLVM. Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py?rev=86530&r1=86529&r2=86530&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py (original) +++ zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Mon Nov 9 02:07:40 2009 @@ -6,9 +6,34 @@ from zorg.buildbot.commands.ClangTestCommand import ClangTestCommand +def getConfigArgs(origname): + name = origname + args = [] + if name.startswith('Release'): + name = name[len('Release'):] + args.append('--enable-optimized') + elif name.startswith('Debug'): + name = name[len('Debug'):] + else: + raise ValueError,'Unknown config name: %r' % origname + + if name.startswith('-Asserts'): + name = name[len('-Asserts'):] + args.append('--disable-assertions') + + if name.startswith('+Checks'): + name = name[len('+Checks'):] + args.append('--enable-expensive-checks') + + if name: + raise ValueError,'Unknown config name: %r' % origname + + return args + def getLLVMGCCBuildFactory(jobs=1, update=True, clean=True, gxxincludedir=None, triple=None, - useTwoStage=True): + useTwoStage=True, stage1_config='Release', + stage2_config='Release'): f = buildbot.process.factory.BuildFactory() # Determine the build directory. @@ -45,13 +70,16 @@ base_llvm_configure_args.append('--build=' + triple) base_llvm_configure_args.append('--host=' + triple) base_llvm_configure_args.append('--target=' + triple) + stage_configure_args = getConfigArgs(stage1_config) f.addStep(Configure(name='configure.llvm.stage1', - command=base_llvm_configure_args + + command=base_llvm_configure_args + + stage_configure_args + ["--without-llvmgcc", "--without-llvmgxx"], description=["configure", "llvm", - "(stage 1)"], + "(stage 1)", + stage1_config], workdir="llvm.obj")) # Build llvm (stage 1). @@ -61,7 +89,7 @@ description=["compile", "llvm", "(stage 1)", - "Debug"], + stage1_config], workdir="llvm.obj")) # Run LLVM tests (stage 1). @@ -140,10 +168,11 @@ workdir=".")) # Configure llvm (stage 2). + stage_configure_args = getConfigArgs(stage2_config) f.addStep(Configure(name="configure.llvm.stage2", command=base_llvm_configure_args + - ["--enable-optimized", - WithProperties("--with-llvmgcc=%(builddir)s/llvm-gcc.install/bin/llvm-gcc"), + stage_configure_args + + [WithProperties("--with-llvmgcc=%(builddir)s/llvm-gcc.install/bin/llvm-gcc"), WithProperties("--with-llvmgxx=%(builddir)s/llvm-gcc.install/bin/llvm-g++")], env={'CC' : WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-gcc"), 'CXX' : WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-g++"),}, @@ -152,7 +181,7 @@ description=["configure", "llvm", "(stage 2)", - "Release"])) + stage2_config])) # Build LLVM (stage 2). f.addStep(WarningCountingShellCommand(name = "compile.llvm.stage2", @@ -161,7 +190,7 @@ description=["compile", "llvm", "(stage 2)", - "Release"], + stage2_config], workdir="llvm.obj.2")) # Run LLVM tests (stage 2). From baldrick at free.fr Mon Nov 9 02:10:45 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 08:10:45 -0000 Subject: [llvm-commits] [dragonegg] r86531 - /dragonegg/trunk/llvm-types.cpp Message-ID: <200911090810.nA98Aj7n015574@zion.cs.uiuc.edu> Author: baldrick Date: Mon Nov 9 02:10:45 2009 New Revision: 86531 URL: http://llvm.org/viewvc/llvm-project?rev=86531&view=rev Log: Fix build after header include changes in LLVM. Modified: dragonegg/trunk/llvm-types.cpp Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=86531&r1=86530&r2=86531&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Mon Nov 9 02:10:45 2009 @@ -35,6 +35,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/ErrorHandling.h" // System headers #include From arplynn at gmail.com Mon Nov 9 04:09:41 2009 From: arplynn at gmail.com (Alastair Lynn) Date: Mon, 9 Nov 2009 10:09:41 +0000 Subject: [llvm-commits] Patch: instcombine on overflow intrinsics Message-ID: <9BC71E21-928E-4502-A49B-6798A580C0C3@gmail.com> Hello- This patch adds the follow to instcombine: overflow intrinsic (undef, X) or overflow intrinsic (X, undef) -> undef add overflow (X, 0) or add overflow (0, X) -> {X, false} unsigned add overflow (X, Y) -> {X + Y, true} where the HO bit is provably 1 in both X and Y unsigned add overflow (X, Y) -> {X + Y, false} where the HO bit is provably 0 in both X and Y sub overflow (X, 0) -> {X, false} mul overflow (X, 0) -> {0, false} mul overflow (X, 1) -> {X, false} Testcase in patch. -------------- next part -------------- A non-text attachment was scrubbed... Name: overflow-instcombine.patch Type: application/octet-stream Size: 9868 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/c86211dc/attachment.obj -------------- next part -------------- From xerxes at zafena.se Mon Nov 9 04:13:55 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 09 Nov 2009 11:13:55 +0100 Subject: [llvm-commits] [patch] Make it possible to enable and disable JIT debug dumps dynamically - namespace fix for new api In-Reply-To: <9906A857-F576-4D30-95AD-6DD0578D127A@apple.com> References: <4AE8685D.2040409@zafena.se> <9906A857-F576-4D30-95AD-6DD0578D127A@apple.com> Message-ID: <4AF7EB63.8090505@zafena.se> Chris Lattner skrev: > > On Oct 28, 2009, at 8:50 AM, Xerxes R?nby wrote: > >> This patch would enable projects that use the LLVM JIT to enable and >> disable JIT debug dumps dynamically. >> The patch have been up for discussion on the llvm-dev mailinglist but >> since it have gotten no attention there im posting it for review here >> instead. >> >> http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-January/019661.html >> http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-May/022101.html >> >> Projects like Icedtea (OpenJDK) that uses the LLVM JIT would benefit >> from this patch since it would enable us to turn on dumping of JITed >> machinecode for selected methods. >> >> Patch made by Andrew Haley. > > Hi Xerxes, > > I spoke with Andrew on IRC and added a new API to do this: > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091026/089863.html > > > Please verify that it works for you guys, > > -Chris > Hi Chris, The new API worked as expected except one small issue, I had to make SetCurrentDebugType part of the llvm namespace in Debug.cpp so that it matches Debug.h or else i get a linking error stating that llvm::SetCurrentDebugType could not get resolved. Ok to push? Cheers Xerxes -------------- next part -------------- A non-text attachment was scrubbed... Name: support_debug_namespace_llvm_SetCurrentDebugType.patch Type: text/x-patch Size: 511 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/d787e5a2/attachment.bin From baldrick at free.fr Mon Nov 9 04:47:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 11:47:58 +0100 Subject: [llvm-commits] Patch: instcombine on overflow intrinsics In-Reply-To: <9BC71E21-928E-4502-A49B-6798A580C0C3@gmail.com> References: <9BC71E21-928E-4502-A49B-6798A580C0C3@gmail.com> Message-ID: <4AF7F35E.2090404@free.fr> Hi Alastair, > This patch adds the follow to instcombine: > overflow intrinsic (undef, X) or overflow intrinsic (X, undef) -> undef > add overflow (X, 0) or add overflow (0, X) -> {X, false} > unsigned add overflow (X, Y) -> {X + Y, true} where the HO bit is > provably 1 in both X and Y > unsigned add overflow (X, Y) -> {X + Y, false} where the HO bit is > provably 0 in both X and Y > sub overflow (X, 0) -> {X, false} > mul overflow (X, 0) -> {0, false} > mul overflow (X, 1) -> {X, false} how about deleting the overflow intrinsics instead, and add IRBuilder helper methods for generating "add with overflow" etc that generate the appropriate apint arithmetic? That way you should get all these optimizations for free, and you won't have to redo a huge chunk of integer optimizations. It may be that codegen doesn't produce optimal code for the apint versions, but in that case it's probably best to improve codegen. Ciao, Duncan. From rafael.espindola at gmail.com Mon Nov 9 08:27:04 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 09 Nov 2009 14:27:04 -0000 Subject: [llvm-commits] [compiler-rt] r86542 - /compiler-rt/trunk/lib/assembly.h Message-ID: <200911091427.nA9ER4Pp014728@zion.cs.uiuc.edu> Author: rafael Date: Mon Nov 9 08:27:04 2009 New Revision: 86542 URL: http://llvm.org/viewvc/llvm-project?rev=86542&view=rev Log: Use __USER_LABEL_PREFIX__ so that we don't add a _ prefix on ELF. Modified: compiler-rt/trunk/lib/assembly.h Modified: compiler-rt/trunk/lib/assembly.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/assembly.h?rev=86542&r1=86541&r2=86542&view=diff ============================================================================== --- compiler-rt/trunk/lib/assembly.h (original) +++ compiler-rt/trunk/lib/assembly.h Mon Nov 9 08:27:04 2009 @@ -25,7 +25,7 @@ #else -#define SYMBOL_NAME(name) _##name +#define SYMBOL_NAME(name) #__USER_LABEL_PREFIX__ ##name #define SEPARATOR ; #endif From bruno.cardoso at gmail.com Mon Nov 9 08:27:49 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 09 Nov 2009 14:27:49 -0000 Subject: [llvm-commits] [llvm] r86543 - in /llvm/trunk/lib/Target/Mips: MipsMachineFunction.h MipsRegisterInfo.cpp Message-ID: <200911091427.nA9ERnbk014775@zion.cs.uiuc.edu> Author: bruno Date: Mon Nov 9 08:27:49 2009 New Revision: 86543 URL: http://llvm.org/viewvc/llvm-project?rev=86543&view=rev Log: Fix PR5149. http://llvm.org/bugs/show_bug.cgi?id=5149 Modified: llvm/trunk/lib/Target/Mips/MipsMachineFunction.h llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Mips/MipsMachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsMachineFunction.h?rev=86543&r1=86542&r2=86543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsMachineFunction.h (original) +++ llvm/trunk/lib/Target/Mips/MipsMachineFunction.h Mon Nov 9 08:27:49 2009 @@ -103,6 +103,7 @@ int getGPFI() const { return GPHolder.FI; } void setGPStackOffset(int Off) { GPHolder.SPOffset = Off; } void setGPFI(int FI) { GPHolder.FI = FI; } + bool needGPSaveRestore() const { return GPHolder.SPOffset != -1; } bool hasLoadArgs() const { return HasLoadArgs; } bool hasStoreVarArgs() const { return HasStoreVarArgs; } Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp?rev=86543&r1=86542&r2=86543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Mon Nov 9 08:27:49 2009 @@ -438,11 +438,10 @@ .addReg(Mips::SP).addReg(Mips::ZERO); } - // PIC speficic function prologue - if ((isPIC) && (MFI->hasCalls())) { + // Restore GP from the saved stack location + if (MipsFI->needGPSaveRestore()) BuildMI(MBB, MBBI, dl, TII.get(Mips::CPRESTORE)) .addImm(MipsFI->getGPStackOffset()); - } } void MipsRegisterInfo:: @@ -489,13 +488,11 @@ void MipsRegisterInfo:: processFunctionBeforeFrameFinalized(MachineFunction &MF) const { - // Set the SPOffset on the FI where GP must be saved/loaded. + // Set the stack offset where GP must be saved/loaded from. MachineFrameInfo *MFI = MF.getFrameInfo(); - bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_); - if (MFI->hasCalls() && isPIC) { - MipsFunctionInfo *MipsFI = MF.getInfo(); + MipsFunctionInfo *MipsFI = MF.getInfo(); + if (MipsFI->needGPSaveRestore()) MFI->setObjectOffset(MipsFI->getGPFI(), MipsFI->getGPStackOffset()); - } } unsigned MipsRegisterInfo:: From xerxes at zafena.se Mon Nov 9 08:50:35 2009 From: xerxes at zafena.se (Xerxes Ranby) Date: Mon, 09 Nov 2009 14:50:35 -0000 Subject: [llvm-commits] [llvm] r86544 - /llvm/trunk/lib/Support/Debug.cpp Message-ID: <200911091450.nA9EoZxM015594@zion.cs.uiuc.edu> Author: xranby Date: Mon Nov 9 08:50:34 2009 New Revision: 86544 URL: http://llvm.org/viewvc/llvm-project?rev=86544&view=rev Log: Make lib/Support/Debug.cpp SetCurrentDebugType implementation part of llvm namespace to match function declaration in Debug.h. Modified: llvm/trunk/lib/Support/Debug.cpp Modified: llvm/trunk/lib/Support/Debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Debug.cpp?rev=86544&r1=86543&r2=86544&view=diff ============================================================================== --- llvm/trunk/lib/Support/Debug.cpp (original) +++ llvm/trunk/lib/Support/Debug.cpp Mon Nov 9 08:50:34 2009 @@ -62,7 +62,7 @@ /// option were specified. Note that DebugFlag also needs to be set to true for /// debug output to be produced. /// -void SetCurrentDebugType(const char *Type) { +void llvm::SetCurrentDebugType(const char *Type) { CurrentDebugType = Type; } From xerxes at zafena.se Mon Nov 9 08:53:52 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 09 Nov 2009 15:53:52 +0100 Subject: [llvm-commits] [patch] Make it possible to enable and disable JIT debug dumps dynamically - namespace fix for new api In-Reply-To: <4AF7EB63.8090505@zafena.se> References: <4AE8685D.2040409@zafena.se> <9906A857-F576-4D30-95AD-6DD0578D127A@apple.com> <4AF7EB63.8090505@zafena.se> Message-ID: <4AF82D00.3070307@zafena.se> I have commited the small namespace fix for this new API in: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091109/090686.html Cheers, and have a great day! Xerxes Xerxes R?nby skrev: > Chris Lattner skrev: > >> On Oct 28, 2009, at 8:50 AM, Xerxes R?nby wrote: >> >> >>> This patch would enable projects that use the LLVM JIT to enable and >>> disable JIT debug dumps dynamically. >>> The patch have been up for discussion on the llvm-dev mailinglist but >>> since it have gotten no attention there im posting it for review here >>> instead. >>> >>> http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-January/019661.html >>> http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-May/022101.html >>> >>> Projects like Icedtea (OpenJDK) that uses the LLVM JIT would benefit >>> from this patch since it would enable us to turn on dumping of JITed >>> machinecode for selected methods. >>> >>> Patch made by Andrew Haley. >>> >> Hi Xerxes, >> >> I spoke with Andrew on IRC and added a new API to do this: >> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091026/089863.html >> >> >> Please verify that it works for you guys, >> >> -Chris >> >> > Hi Chris, > > The new API worked as expected except one small issue, I had to make > SetCurrentDebugType part of the llvm namespace in Debug.cpp so that it > matches Debug.h or else i get a linking error stating that > llvm::SetCurrentDebugType could not get resolved. > > Ok to push? > > Cheers > Xerxes > > ------------------------------------------------------------------------ > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ofv at wanadoo.es Mon Nov 9 09:26:43 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 09 Nov 2009 15:26:43 -0000 Subject: [llvm-commits] [llvm] r86547 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake Message-ID: <200911091526.nA9FQhRr016776@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 9 09:26:40 2009 New Revision: 86547 URL: http://llvm.org/viewvc/llvm-project?rev=86547&view=rev Log: CMake: Detect gv, circo, twopi, neato, fdo, dot and dotty. Patch by Arnaud Allard de Grandmaison! Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/include/llvm/Config/config.h.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86547&r1=86546&r2=86547&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Mon Nov 9 09:26:40 2009 @@ -127,13 +127,26 @@ check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T) # available programs checks -find_program(DOTTY_EXECUTABLE dotty) -if(DOTTY_EXECUTABLE) - set(HAVE_DOTTY 1) - set(LLVM_PATH_DOTTY ${DOTTY_EXECUTABLE}) - mark_as_advanced(HAVE_DOTTY) - mark_as_advanced(LLVM_PATH_DOTTY) -endif() +function(llvm_find_program name) + string(TOUPPER ${name} NAME) + find_program(LLVM_PATH_${NAME} ${name}) + mark_as_advanced(LLVM_PATH_${NAME}) + if(LLVM_PATH_${NAME}) + set(HAVE_${NAME} 1 CACHE INTERNAL "Is ${name} available ?") + mark_as_advanced(HAVE_${NAME}) + else(LLVM_PATH_${NAME}) + set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?") + unset(LLVM_PATH_${NAME} CACHE) + endif(LLVM_PATH_${NAME}) +endfunction() + +llvm_find_program(gv) +llvm_find_program(circo) +llvm_find_program(twopi) +llvm_find_program(neato) +llvm_find_program(fdp) +llvm_find_program(dot) +llvm_find_program(dotty) # Define LLVM_MULTITHREADED if gcc atomic builtins exists. include(CheckAtomic) Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=86547&r1=86546&r2=86547&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Mon Nov 9 09:26:40 2009 @@ -48,6 +48,9 @@ /* Define to 1 if you have the `ceilf' function. */ #cmakedefine HAVE_CEILF ${HAVE_CEILF} +/* Define if the neat program is available */ +#cmakedefine HAVE_CIRCO ${HAVE_CIRCO} + /* Define to 1 if you have the `closedir' function. */ #undef HAVE_CLOSEDIR @@ -77,7 +80,7 @@ #cmakedefine HAVE_DL_H ${HAVE_DL_H} /* Define if the dot program is available */ -#undef HAVE_DOT +#cmakedefine HAVE_DOT ${HAVE_DOT} /* Define if the dotty program is available */ #cmakedefine HAVE_DOTTY ${HAVE_DOTTY} @@ -97,6 +100,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H} +/* Define if the neat program is available */ +#cmakedefine HAVE_FDP ${HAVE_FDP} + /* Set to 1 if the finite function is found in */ #cmakedefine HAVE_FINITE_IN_IEEEFP_H ${HAVE_FINITE_IN_IEEEFP_H} @@ -137,7 +143,7 @@ #undef HAVE_GRAPHVIZ /* Define if the gv program is available */ -#undef HAVE_GV +#cmakedefine HAVE_GV ${HAVE_GV} /* Define to 1 if you have the `index' function. */ #undef HAVE_INDEX @@ -249,6 +255,9 @@ /* Define to 1 if you have the `nearbyintf' function. */ #undef HAVE_NEARBYINTF +/* Define if the neat program is available */ +#cmakedefine HAVE_NEATO ${HAVE_NEATO} + /* Define to 1 if you have the `opendir' function. */ #undef HAVE_OPENDIR @@ -410,6 +419,9 @@ /* Define to 1 if you have that is POSIX.1 compatible. */ #cmakedefine HAVE_SYS_WAIT_H ${HAVE_SYS_WAIT_H} +/* Define if the neat program is available */ +#cmakedefine HAVE_TWOPI ${HAVE_TWOPI} + /* Define to 1 if the system has the type `uint64_t'. */ #undef HAVE_UINT64_T @@ -467,17 +479,29 @@ /* Added by Kevin -- Maximum path length */ #cmakedefine MAXPATHLEN ${MAXPATHLEN} +/* Define to path to circo program if found or 'echo circo' otherwise */ +#cmakedefine LLVM_PATH_CIRCO "${LLVM_PATH_CIRCO}" + /* Define to path to dot program if found or 'echo dot' otherwise */ -#undef LLVM_PATH_DOT +#cmakedefine LLVM_PATH_DOT "${LLVM_PATH_DOT}" /* Define to path to dotty program if found or 'echo dotty' otherwise */ #cmakedefine LLVM_PATH_DOTTY "${LLVM_PATH_DOTTY}" +/* Define to path to fdp program if found or 'echo fdp' otherwise */ +#cmakedefine LLVM_PATH_FDP "${LLVM_PATH_FDP}" + /* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */ #undef LLVM_PATH_GRAPHVIZ /* Define to path to gv program if found or 'echo gv' otherwise */ -#undef LLVM_PATH_GV +#cmakedefine LLVM_PATH_GV "${LLVM_PATH_GV}" + +/* Define to path to neato program if found or 'echo neato' otherwise */ +#cmakedefine LLVM_PATH_NEATO "${LLVM_PATH_NEATO}" + +/* Define to path to twopi program if found or 'echo twopi' otherwise */ +#cmakedefine LLVM_PATH_TWOPI "${LLVM_PATH_TWOPI}" /* Installation prefix directory */ #undef LLVM_PREFIX From grosbach at apple.com Mon Nov 9 09:27:51 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 Nov 2009 15:27:51 -0000 Subject: [llvm-commits] [llvm] r86548 - /llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Message-ID: <200911091527.nA9FRprg016845@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 9 09:27:51 2009 New Revision: 86548 URL: http://llvm.org/viewvc/llvm-project?rev=86548&view=rev Log: Work around assembler not recognizing #0.0 form immediate for vmcp Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=86548&r1=86547&r2=86548&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Mon Nov 9 09:27:51 2009 @@ -194,11 +194,11 @@ let Defs = [FPSCR] in { def VCMPEZD : ADuI<0b11101011, 0b0101, 0b1100, (outs), (ins DPR:$a), - IIC_fpCMP64, "vcmpe", ".f64\t$a, #0.0", + IIC_fpCMP64, "vcmpe", ".f64\t$a, #0", [(arm_cmpfp0 DPR:$a)]>; def VCMPEZS : ASuI<0b11101011, 0b0101, 0b1100, (outs), (ins SPR:$a), - IIC_fpCMP32, "vcmpe", ".f32\t$a, #0.0", + IIC_fpCMP32, "vcmpe", ".f32\t$a, #0", [(arm_cmpfp0 SPR:$a)]>; } From nunoplopes at sapo.pt Mon Nov 9 09:36:28 2009 From: nunoplopes at sapo.pt (Nuno Lopes) Date: Mon, 09 Nov 2009 15:36:28 -0000 Subject: [llvm-commits] [llvm] r86549 - in /llvm/trunk: include/llvm/Support/ConstantRange.h lib/Support/ConstantRange.cpp Message-ID: <200911091536.nA9FaSji017134@zion.cs.uiuc.edu> Author: nlopes Date: Mon Nov 9 09:36:28 2009 New Revision: 86549 URL: http://llvm.org/viewvc/llvm-project?rev=86549&view=rev Log: add zextOrTrunc and sextOrTrunc methods, that are similar to the ones in APInt Modified: llvm/trunk/include/llvm/Support/ConstantRange.h llvm/trunk/lib/Support/ConstantRange.cpp Modified: llvm/trunk/include/llvm/Support/ConstantRange.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantRange.h?rev=86549&r1=86548&r2=86549&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantRange.h (original) +++ llvm/trunk/include/llvm/Support/ConstantRange.h Mon Nov 9 09:36:28 2009 @@ -187,6 +187,14 @@ /// truncated to the specified type. ConstantRange truncate(uint32_t BitWidth) const; + /// zextOrTrunc - make this range have the bit width given by \p BitWidth. The + /// value is zero extended, truncated, or left alone to make it that width. + ConstantRange zextOrTrunc(uint32_t BitWidth) const; + + /// sextOrTrunc - make this range have the bit width given by \p BitWidth. The + /// value is sign extended, truncated, or left alone to make it that width. + ConstantRange sextOrTrunc(uint32_t BitWidth) const; + /// add - Return a new range representing the possible values resulting /// from an addition of a value in this range and a value in Other. ConstantRange add(const ConstantRange &Other) const; Modified: llvm/trunk/lib/Support/ConstantRange.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=86549&r1=86548&r2=86549&view=diff ============================================================================== --- llvm/trunk/lib/Support/ConstantRange.cpp (original) +++ llvm/trunk/lib/Support/ConstantRange.cpp Mon Nov 9 09:36:28 2009 @@ -492,6 +492,30 @@ return ConstantRange(L, U); } +/// zextOrTrunc - make this range have the bit width given by \p DstTySize. The +/// value is zero extended, truncated, or left alone to make it that width. +ConstantRange ConstantRange::zextOrTrunc(uint32_t DstTySize) const { + unsigned SrcTySize = getBitWidth(); + if (SrcTySize > DstTySize) + return truncate(DstTySize); + else if (SrcTySize < DstTySize) + return zeroExtend(DstTySize); + else + return *this; +} + +/// sextOrTrunc - make this range have the bit width given by \p DstTySize. The +/// value is sign extended, truncated, or left alone to make it that width. +ConstantRange ConstantRange::sextOrTrunc(uint32_t DstTySize) const { + unsigned SrcTySize = getBitWidth(); + if (SrcTySize > DstTySize) + return truncate(DstTySize); + else if (SrcTySize < DstTySize) + return signExtend(DstTySize); + else + return *this; +} + ConstantRange ConstantRange::add(const ConstantRange &Other) const { if (isEmptySet() || Other.isEmptySet()) From baldrick at free.fr Mon Nov 9 10:32:02 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 17:32:02 +0100 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> Message-ID: <4AF84402.1070300@free.fr> Hi Kenneth, > + // True if the function needs to be sret-demoted > + bool CantLowerReturn; rather than using a negative, how about CanLowerReturn? > + /// getCantLowerReturn - Return true if the function needs sret-demotion. The name exposes the implementation (accessing an internal variable called CantLowerReturn) rather than the logical function. How about negating it and calling it "canLowerReturn". > + bool CanLowerReturn = TLI.CanLowerReturn(CS.getCallingConv(), > + FTy->isVarArg(), OutVTs, OutsFlags, DAG); Isn't it confusing to have several Can/Cant's. What's the connection between them? I'm not competent to comment on the rest of the patch. Ciao, Duncan. From daniel at zuster.org Mon Nov 9 10:38:16 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 16:38:16 -0000 Subject: [llvm-commits] [llvm] r86553 - in /llvm/trunk/test: FrontendC++/2006-11-06-StackTrace.cpp FrontendC++/2006-11-30-NoCompileUnit.cpp FrontendC++/2006-11-30-Pubnames.cpp FrontendC/Atomics-no64bit.c FrontendC/Atomics.c Message-ID: <200911091638.nA9GcGWO019586@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 10:38:15 2009 New Revision: 86553 URL: http://llvm.org/viewvc/llvm-project?rev=86553&view=rev Log: Use ',' separation in XFAILs, lit doesn't evaluate them as regexs (easy to add, but might as well use the more standard syntax). Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp llvm/trunk/test/FrontendC/Atomics-no64bit.c llvm/trunk/test/FrontendC/Atomics.c Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=86553&r1=86552&r2=86553&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Mon Nov 9 10:38:15 2009 @@ -12,7 +12,7 @@ // Only works on ppc (but not apple-darwin9), x86 and x86_64. Should // generalize? -// XFAIL: alpha|arm|powerpc-apple-darwin9 +// XFAIL: alpha,arm,powerpc-apple-darwin9 #include Modified: llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-NoCompileUnit.cpp?rev=86553&r1=86552&r2=86553&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp Mon Nov 9 10:38:15 2009 @@ -7,7 +7,7 @@ // RUN: echo {break main\nrun\np NoCompileUnit::pubname} > %t2 // RUN: gdb -q -batch -n -x %t2 NoCompileUnit.exe | \ // RUN: tee NoCompileUnit.out | not grep {"low == high"} -// XFAIL: alpha|arm +// XFAIL: alpha,arm // XFAIL: * // See PR2454 Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-Pubnames.cpp?rev=86553&r1=86552&r2=86553&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp Mon Nov 9 10:38:15 2009 @@ -7,7 +7,7 @@ // RUN: %llvmdsymutil %t.exe // RUN: echo {break main\nrun\np Pubnames::pubname} > %t.in // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | grep {\$1 = 10} -// XFAIL: alpha|arm +// XFAIL: alpha,arm struct Pubnames { static int pubname; }; Modified: llvm/trunk/test/FrontendC/Atomics-no64bit.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/Atomics-no64bit.c?rev=86553&r1=86552&r2=86553&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/Atomics-no64bit.c (original) +++ llvm/trunk/test/FrontendC/Atomics-no64bit.c Mon Nov 9 10:38:15 2009 @@ -9,7 +9,7 @@ // Currently this is implemented only for Alpha, X86, PowerPC. // Add your target here if it doesn't work. // This version of the test does not include long long. -// XFAIL: sparc|arm +// XFAIL: sparc,arm signed char sc; unsigned char uc; Modified: llvm/trunk/test/FrontendC/Atomics.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/Atomics.c?rev=86553&r1=86552&r2=86553&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/Atomics.c (original) +++ llvm/trunk/test/FrontendC/Atomics.c Mon Nov 9 10:38:15 2009 @@ -9,7 +9,7 @@ // Currently this is implemented only for Alpha, X86, PowerPC. // Add your target here if it doesn't work. // PPC32 does not translate the long long variants, so fails this test. -// XFAIL: sparc|arm|powerpc +// XFAIL: sparc,arm,powerpc signed char sc; unsigned char uc; From kennethuil at gmail.com Mon Nov 9 10:44:20 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 9 Nov 2009 10:44:20 -0600 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <4AF84402.1070300@free.fr> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <4AF84402.1070300@free.fr> Message-ID: <400d33ea0911090844p6b465da5l1b9b228a8c36beb1@mail.gmail.com> On Mon, Nov 9, 2009 at 10:32 AM, Duncan Sands wrote: > Hi Kenneth, > >> + ?// True if the function needs to be sret-demoted >> + ?bool CantLowerReturn; > > rather than using a negative, how about CanLowerReturn? I had the notion that we usually tried to default flags to false. > >> + ?/// getCantLowerReturn - Return true if the function needs >> sret-demotion. > > The name exposes the implementation (accessing an internal variable called > CantLowerReturn) rather than the logical function. ?How about negating it > and > calling it "canLowerReturn". Excellent idea. I'll do that. > >> + ?bool CanLowerReturn = TLI.CanLowerReturn(CS.getCallingConv(), + >> ? ? ? ? ? ? ? ?FTy->isVarArg(), OutVTs, OutsFlags, DAG); > > Isn't it confusing to have several Can/Cant's. ?What's the connection > between > them? TargetLowering::CanLowerReturn checks lowerability against the target implementation of the calling convention. In SelectionDAGISel::LowerArguments, I'm calling TargetLowering::CanLowerReturn once, then stashing that information (along with a virtual reg to hold the inserted sret parameter, if CanLowerReturn returns false) in the MachineFunction (the CantLowerReturn flag and the DemoteRegister field) so I don't have to keep calling CanLowerReturn each time I hit a return instruction (handled by SelectionDAGLowering::visitRet) in that same function. I'm assuming, of course, that (a) LowerFormalArguments always gets called before visitRet and (b) the same MachineFunction instance always comes back whenever visitXXX or LowerXXX is called to process code within the same function. If either assumption is bogus, then my code is broken. From gohman at apple.com Mon Nov 9 11:06:24 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 17:06:24 -0000 Subject: [llvm-commits] [llvm] r86557 - /llvm/trunk/include/llvm/CodeGen/MachineFunction.h Message-ID: <200911091706.nA9H6OpJ020714@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 11:06:23 2009 New Revision: 86557 URL: http://llvm.org/viewvc/llvm-project?rev=86557&view=rev Log: Suppress implicit copy ctor and copy assignment for MachineFunction. Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=86557&r1=86556&r2=86557&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Mon Nov 9 11:06:23 2009 @@ -115,6 +115,9 @@ // The alignment of the function. unsigned Alignment; + MachineFunction(const MachineFunction &); // intentionally unimplemented + void operator=(const MachineFunction&); // intentionally unimplemented + public: MachineFunction(Function *Fn, const TargetMachine &TM); ~MachineFunction(); From gohman at apple.com Mon Nov 9 11:06:52 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 17:06:52 -0000 Subject: [llvm-commits] [llvm] r86558 - /llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200911091706.nA9H6qLN020735@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 11:06:51 2009 New Revision: 86558 URL: http://llvm.org/viewvc/llvm-project?rev=86558&view=rev Log: Fix a comment. Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=86558&r1=86557&r2=86558&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Mon Nov 9 11:06:51 2009 @@ -246,7 +246,7 @@ /// transferSuccessors - Transfers all the successors from MBB to this /// machine basic block (i.e., copies all the successors fromMBB and - /// remove all the successors fromBB). + /// remove all the successors from fromMBB). void transferSuccessors(MachineBasicBlock *fromMBB); /// isSuccessor - Return true if the specified MBB is a successor of this From gohman at apple.com Mon Nov 9 12:18:49 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:18:49 -0000 Subject: [llvm-commits] [llvm] r86564 - in /llvm/trunk: include/llvm/CodeGen/MachineFunctionAnalysis.h lib/CodeGen/MachineFunctionAnalysis.cpp Message-ID: <200911091818.nA9IIn23023964@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:18:49 2009 New Revision: 86564 URL: http://llvm.org/viewvc/llvm-project?rev=86564&view=rev Log: Constify MachineFunctionAnalysis' TargetMachine reference. Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h?rev=86564&r1=86563&r2=86564&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h Mon Nov 9 12:18:49 2009 @@ -31,7 +31,7 @@ public: static char ID; - explicit MachineFunctionAnalysis(TargetMachine &tm, + explicit MachineFunctionAnalysis(const TargetMachine &tm, CodeGenOpt::Level OL = CodeGenOpt::Default); ~MachineFunctionAnalysis(); Modified: llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp?rev=86564&r1=86563&r2=86564&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp Mon Nov 9 12:18:49 2009 @@ -24,7 +24,7 @@ char MachineFunctionAnalysis::ID = 0; -MachineFunctionAnalysis::MachineFunctionAnalysis(TargetMachine &tm, +MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm, CodeGenOpt::Level OL) : FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) { } From gohman at apple.com Mon Nov 9 12:19:43 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:19:43 -0000 Subject: [llvm-commits] [llvm] r86565 - /llvm/trunk/lib/Analysis/LoopInfo.cpp Message-ID: <200911091819.nA9IJiA6024004@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:19:43 2009 New Revision: 86565 URL: http://llvm.org/viewvc/llvm-project?rev=86565&view=rev Log: Minor tidiness fixes. Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=86565&r1=86564&r2=86565&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LoopInfo.cpp Mon Nov 9 12:19:43 2009 @@ -263,14 +263,13 @@ SmallPtrSet LoopBBs(block_begin(), block_end()); for (block_iterator BI = block_begin(), E = block_end(); BI != E; ++BI) { - BasicBlock *BB = *BI; - for (BasicBlock ::iterator I = BB->begin(), E = BB->end(); I != E;++I) + BasicBlock *BB = *BI; + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;++I) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) { BasicBlock *UserBB = cast(*UI)->getParent(); - if (PHINode *P = dyn_cast(*UI)) { + if (PHINode *P = dyn_cast(*UI)) UserBB = P->getIncomingBlock(UI); - } // Check the current block, as a fast-path. Most values are used in // the same block they are defined in. From gohman at apple.com Mon Nov 9 12:20:38 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:20:38 -0000 Subject: [llvm-commits] [llvm] r86567 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h Message-ID: <200911091820.nA9IKcOx024057@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:20:38 2009 New Revision: 86567 URL: http://llvm.org/viewvc/llvm-project?rev=86567&view=rev Log: Fix an 80-column violation. Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=86567&r1=86566&r2=86567&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Mon Nov 9 12:20:38 2009 @@ -114,8 +114,8 @@ block_iterator block_begin() const { return Blocks.begin(); } block_iterator block_end() const { return Blocks.end(); } - /// isLoopExiting - True if terminator in the block can branch to another block - /// that is outside of the current loop. + /// isLoopExiting - True if terminator in the block can branch to another + /// block that is outside of the current loop. /// bool isLoopExiting(const BlockT *BB) const { typedef GraphTraits BlockTraits; From gohman at apple.com Mon Nov 9 12:28:24 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:28:24 -0000 Subject: [llvm-commits] [llvm] r86569 - in /llvm/trunk: lib/Transforms/Utils/LCSSA.cpp test/Transforms/LCSSA/indirectbr.ll Message-ID: <200911091828.nA9ISOw3024412@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:28:24 2009 New Revision: 86569 URL: http://llvm.org/viewvc/llvm-project?rev=86569&view=rev Log: Generalize LCSSA to handle loops with exits with predecessors outside the loop. This is needed because with indirectbr it may not be possible for LoopSimplify to guarantee that all loop exit predecessors are inside the loop. This fixes PR5437. LCCSA no longer actually requires LoopSimplify form, but for now it must still have the dependency because the PassManager doesn't know how to schedule LoopSimplify otherwise. Added: llvm/trunk/test/Transforms/LCSSA/indirectbr.ll Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=86569&r1=86568&r2=86569&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Mon Nov 9 12:28:24 2009 @@ -63,6 +63,9 @@ /// virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); + + // LCSSA doesn't actually require LoopSimplify, but the PassManager + // doesn't know how to schedule LoopSimplify by itself. AU.addRequiredID(LoopSimplifyID); AU.addPreservedID(LoopSimplifyID); AU.addRequiredTransitive(); @@ -214,7 +217,7 @@ SSAUpdate.Initialize(Inst); // Insert the LCSSA phi's into all of the exit blocks dominated by the - // value., and add them to the Phi's map. + // value, and add them to the Phi's map. for (SmallVectorImpl::const_iterator BBI = ExitBlocks.begin(), BBE = ExitBlocks.end(); BBI != BBE; ++BBI) { BasicBlock *ExitBB = *BBI; @@ -228,8 +231,17 @@ PN->reserveOperandSpace(PredCache.GetNumPreds(ExitBB)); // Add inputs from inside the loop for this PHI. - for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) + for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) { PN->addIncoming(Inst, *PI); + + // If the exit block has a predecessor not within the loop, arrange for + // the incomging value use corresponding to that predecessor to be + // rewritten in terms of a different LCSSA PHI. + if (!inLoop(*PI)) + UsesToRewrite.push_back( + &PN->getOperandUse( + PN->getOperandNumForIncomingValue(PN->getNumIncomingValues()-1))); + } // Remember that this phi makes the value alive in this block. SSAUpdate.AddAvailableValue(ExitBB, PN); Added: llvm/trunk/test/Transforms/LCSSA/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LCSSA/indirectbr.ll?rev=86569&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LCSSA/indirectbr.ll (added) +++ llvm/trunk/test/Transforms/LCSSA/indirectbr.ll Mon Nov 9 12:28:24 2009 @@ -0,0 +1,635 @@ +; RUN: opt < %s -lcssa -verify-loop-info -verify-dom-info -disable-output +; PR5437 + +; LCSSA should work correctly in the case of an indirectbr that exits +; the loop, and the loop has exits with predecessors not within the loop +; (and btw these edges are unsplittable due to the indirectbr). + +define i32 @js_Interpret() nounwind { +entry: + br i1 undef, label %"4", label %"3" + +"3": ; preds = %entry + ret i32 0 + +"4": ; preds = %entry + br i1 undef, label %"6", label %"5" + +"5": ; preds = %"4" + unreachable + +"6": ; preds = %"4" + br i1 undef, label %"10", label %"13" + +"10": ; preds = %"6" + br i1 undef, label %"22", label %"15" + +"13": ; preds = %"6" + unreachable + +"15": ; preds = %"23", %"10" + unreachable + +"22": ; preds = %"10" + br label %"23" + +"23": ; preds = %"1375", %"22" + %0 = phi i32 [ undef, %"22" ], [ %1, %"1375" ] ; [#uses=1] + indirectbr i8* undef, [label %"15", label %"24", label %"25", label %"26", label %"27", label %"28", label %"29", label %"30", label %"32", label %"32", label %"33", label %"35", label %"36", label %"41", label %"41", label %"60", label %"61", label %"65", label %"76", label %"87", label %"95", label %"103", label %"104", label %"108", label %"119", label %"130", label %"138", label %"146", label %"164", label %"162", label %"163", label %"166", label %"167", label %"173", label %"173", label %"173", label %"173", label %"173", label %"192", label %"193", label %"194", label %"196", label %"206", label %"231", label %"241", label %"251", label %"261", label %"307", label %"353", label %"354", label %"355", label %"361", label %"367", label %"400", label %"433", label %"466", label %"499", label %"509", label %"519", label %"529", label %"571", label %"589", label %"607", label %"635", label %"655", label %"664", label %"671", label %"680", label %"687", label %"692", labe! l %"698", label %"704", label %"715", label %"715", label %"716", label %"725", label %"725", label %"725", label %"725", label %"724", label %"724", label %"724", label %"724", label %"737", label %"737", label %"737", label %"737", label %"761", label %"758", label %"759", label %"760", label %"766", label %"763", label %"764", label %"765", label %"771", label %"768", label %"769", label %"770", label %"780", label %"777", label %"778", label %"779", label %"821", label %"826", label %"831", label %"832", label %"833", label %"836", label %"836", label %"886", label %"905", label %"978", label %"978", label %"1136", label %"1166", label %"1179", label %"1201", label %"1212", label %"1212", label %"1274", label %"1284", label %"1284", label %"1346", label %"1347", label %"1348", label %"1349", label %"1350", label %"1353", label %"1353", label %"1353", label %"1355", label %"1355", label %"1357", label %"1357", label %"1358", label %"1359", label %"1374", label %"1375", l! abel %"1376", label %"1377", label %"1378", label %"1379", lab! el %"138 6", label %"1395", label %"1394", label %"1425", label %"1426", label %"1440", label %"1449", label %"1455", label %"1461", label %"1471", label %"1482", label %"1484", label %"1486", label %"1489", label %"1489", label %"1492", label %"1494", label %"1494", label %"1497", label %"1499", label %"1499", label %"1515", label %"1546", label %"1546", label %"1566", label %"1584", label %"1587", label %"1591", label %"1605", label %"1609", label %"1609", label %"1640", label %"1648", label %"1651", label %"1703", label %"1710", label %"1718", label %"1724", label %"1725", label %"1726", label %"1727", label %"1728", label %"1731", label %"1732", label %"1733", label %"1734", label %"1735", label %"1741", label %"1750", label %"1752", label %"1754", label %"1755", label %"1757", label %"1759", label %"1761", label %"1764", label %"1764", label %"1766", label %"1768", label %"1775", label %"1775", label %"1781", label %"1781", label %"1790", label %"1791", label %"1801", label %"18! 02", label %"1803", label %"1805", label %"1807", label %"1809", label %"1817", label %"1819", label %"1821", label %"1823", label %"1825", label %"1827", label %"1836", label %"1836", label %"1845", label %"1845", label %"1848", label %"1849", label %"1851", label %"1853", label %"1856", label %"1861", label %"1861"] + +"24": ; preds = %"23" + unreachable + +"25": ; preds = %"23" + unreachable + +"26": ; preds = %"23" + unreachable + +"27": ; preds = %"23" + unreachable + +"28": ; preds = %"23" + unreachable + +"29": ; preds = %"23" + unreachable + +"30": ; preds = %"23" + unreachable + +"32": ; preds = %"23", %"23" + unreachable + +"33": ; preds = %"23" + unreachable + +"35": ; preds = %"23" + unreachable + +"36": ; preds = %"23" + unreachable + +"60": ; preds = %"23" + unreachable + +"61": ; preds = %"23" + unreachable + +"65": ; preds = %"23" + unreachable + +"76": ; preds = %"23" + unreachable + +"87": ; preds = %"23" + unreachable + +"95": ; preds = %"23" + unreachable + +"103": ; preds = %"23" + unreachable + +"104": ; preds = %"23" + unreachable + +"108": ; preds = %"23" + unreachable + +"119": ; preds = %"23" + unreachable + +"130": ; preds = %"23" + unreachable + +"138": ; preds = %"23" + unreachable + +"146": ; preds = %"23" + unreachable + +"162": ; preds = %"23" + unreachable + +"163": ; preds = %"23" + unreachable + +"164": ; preds = %"23" + unreachable + +"166": ; preds = %"23" + unreachable + +"167": ; preds = %"23" + unreachable + +"173": ; preds = %"23", %"23", %"23", %"23", %"23" + unreachable + +"192": ; preds = %"23" + unreachable + +"193": ; preds = %"23" + unreachable + +"194": ; preds = %"23" + unreachable + +"196": ; preds = %"23" + unreachable + +"206": ; preds = %"23" + unreachable + +"231": ; preds = %"23" + unreachable + +"241": ; preds = %"23" + unreachable + +"251": ; preds = %"23" + unreachable + +"261": ; preds = %"23" + unreachable + +"307": ; preds = %"23" + unreachable + +"353": ; preds = %"23" + unreachable + +"354": ; preds = %"23" + unreachable + +"355": ; preds = %"23" + unreachable + +"361": ; preds = %"23" + unreachable + +"367": ; preds = %"23" + unreachable + +"400": ; preds = %"23" + unreachable + +"433": ; preds = %"23" + unreachable + +"466": ; preds = %"23" + unreachable + +"499": ; preds = %"23" + unreachable + +"509": ; preds = %"23" + unreachable + +"519": ; preds = %"23" + unreachable + +"529": ; preds = %"23" + unreachable + +"571": ; preds = %"23" + unreachable + +"589": ; preds = %"23" + unreachable + +"607": ; preds = %"23" + unreachable + +"635": ; preds = %"23" + unreachable + +"655": ; preds = %"23" + unreachable + +"664": ; preds = %"23" + unreachable + +"671": ; preds = %"23" + unreachable + +"680": ; preds = %"23" + unreachable + +"687": ; preds = %"23" + unreachable + +"692": ; preds = %"23" + br label %"1862" + +"698": ; preds = %"23" + unreachable + +"704": ; preds = %"23" + unreachable + +"715": ; preds = %"23", %"23" + unreachable + +"716": ; preds = %"23" + unreachable + +"724": ; preds = %"23", %"23", %"23", %"23" + unreachable + +"725": ; preds = %"23", %"23", %"23", %"23" + unreachable + +"737": ; preds = %"23", %"23", %"23", %"23" + unreachable + +"758": ; preds = %"23" + unreachable + +"759": ; preds = %"23" + unreachable + +"760": ; preds = %"23" + unreachable + +"761": ; preds = %"23" + unreachable + +"763": ; preds = %"23" + unreachable + +"764": ; preds = %"23" + unreachable + +"765": ; preds = %"23" + br label %"766" + +"766": ; preds = %"765", %"23" + unreachable + +"768": ; preds = %"23" + unreachable + +"769": ; preds = %"23" + unreachable + +"770": ; preds = %"23" + unreachable + +"771": ; preds = %"23" + unreachable + +"777": ; preds = %"23" + unreachable + +"778": ; preds = %"23" + unreachable + +"779": ; preds = %"23" + unreachable + +"780": ; preds = %"23" + unreachable + +"821": ; preds = %"23" + unreachable + +"826": ; preds = %"23" + unreachable + +"831": ; preds = %"23" + unreachable + +"832": ; preds = %"23" + unreachable + +"833": ; preds = %"23" + unreachable + +"836": ; preds = %"23", %"23" + unreachable + +"886": ; preds = %"23" + unreachable + +"905": ; preds = %"23" + unreachable + +"978": ; preds = %"23", %"23" + unreachable + +"1136": ; preds = %"23" + unreachable + +"1166": ; preds = %"23" + unreachable + +"1179": ; preds = %"23" + unreachable + +"1201": ; preds = %"23" + unreachable + +"1212": ; preds = %"23", %"23" + unreachable + +"1274": ; preds = %"23" + unreachable + +"1284": ; preds = %"23", %"23" + unreachable + +"1346": ; preds = %"23" + unreachable + +"1347": ; preds = %"23" + unreachable + +"1348": ; preds = %"23" + unreachable + +"1349": ; preds = %"23" + unreachable + +"1350": ; preds = %"23" + unreachable + +"1353": ; preds = %"23", %"23", %"23" + unreachable + +"1355": ; preds = %"23", %"23" + unreachable + +"1357": ; preds = %"23", %"23" + unreachable + +"1358": ; preds = %"23" + unreachable + +"1359": ; preds = %"23" + unreachable + +"1374": ; preds = %"23" + unreachable + +"1375": ; preds = %"23" + %1 = zext i8 undef to i32 ; [#uses=1] + br label %"23" + +"1376": ; preds = %"23" + unreachable + +"1377": ; preds = %"23" + unreachable + +"1378": ; preds = %"23" + unreachable + +"1379": ; preds = %"23" + unreachable + +"1386": ; preds = %"23" + unreachable + +"1394": ; preds = %"23" + unreachable + +"1395": ; preds = %"23" + unreachable + +"1425": ; preds = %"23" + unreachable + +"1426": ; preds = %"23" + unreachable + +"1440": ; preds = %"23" + unreachable + +"1449": ; preds = %"23" + unreachable + +"1455": ; preds = %"23" + unreachable + +"1461": ; preds = %"23" + unreachable + +"1471": ; preds = %"23" + unreachable + +"1482": ; preds = %"23" + unreachable + +"1484": ; preds = %"23" + unreachable + +"1486": ; preds = %"23" + unreachable + +"1489": ; preds = %"23", %"23" + unreachable + +"1492": ; preds = %"23" + unreachable + +"1494": ; preds = %"23", %"23" + unreachable + +"1497": ; preds = %"23" + unreachable + +"1499": ; preds = %"23", %"23" + unreachable + +"1515": ; preds = %"23" + unreachable + +"1546": ; preds = %"23", %"23" + unreachable + +"1566": ; preds = %"23" + br i1 undef, label %"1569", label %"1568" + +"1568": ; preds = %"1566" + unreachable + +"1569": ; preds = %"1566" + unreachable + +"1584": ; preds = %"23" + unreachable + +"1587": ; preds = %"23" + unreachable + +"1591": ; preds = %"23" + unreachable + +"1605": ; preds = %"23" + unreachable + +"1609": ; preds = %"23", %"23" + unreachable + +"1640": ; preds = %"23" + unreachable + +"1648": ; preds = %"23" + unreachable + +"1651": ; preds = %"23" + unreachable + +"1703": ; preds = %"23" + unreachable + +"1710": ; preds = %"23" + unreachable + +"1718": ; preds = %"23" + unreachable + +"1724": ; preds = %"23" + unreachable + +"1725": ; preds = %"23" + unreachable + +"1726": ; preds = %"23" + unreachable + +"1727": ; preds = %"23" + unreachable + +"1728": ; preds = %"23" + unreachable + +"1731": ; preds = %"23" + unreachable + +"1732": ; preds = %"23" + unreachable + +"1733": ; preds = %"23" + unreachable + +"1734": ; preds = %"23" + unreachable + +"1735": ; preds = %"23" + unreachable + +"1741": ; preds = %"23" + unreachable + +"1750": ; preds = %"23" + unreachable + +"1752": ; preds = %"23" + unreachable + +"1754": ; preds = %"23" + unreachable + +"1755": ; preds = %"23" + unreachable + +"1757": ; preds = %"23" + unreachable + +"1759": ; preds = %"23" + unreachable + +"1761": ; preds = %"23" + unreachable + +"1764": ; preds = %"23", %"23" + %2 = icmp eq i32 %0, 168 ; [#uses=0] + unreachable + +"1766": ; preds = %"23" + unreachable + +"1768": ; preds = %"23" + unreachable + +"1775": ; preds = %"23", %"23" + unreachable + +"1781": ; preds = %"23", %"23" + unreachable + +"1790": ; preds = %"23" + unreachable + +"1791": ; preds = %"23" + unreachable + +"1801": ; preds = %"23" + unreachable + +"1802": ; preds = %"23" + unreachable + +"1803": ; preds = %"23" + unreachable + +"1805": ; preds = %"23" + unreachable + +"1807": ; preds = %"23" + unreachable + +"1809": ; preds = %"23" + unreachable + +"1817": ; preds = %"23" + unreachable + +"1819": ; preds = %"23" + unreachable + +"1821": ; preds = %"23" + unreachable + +"1823": ; preds = %"23" + unreachable + +"1825": ; preds = %"23" + unreachable + +"1827": ; preds = %"23" + unreachable + +"1836": ; preds = %"23", %"23" + br label %"1862" + +"1845": ; preds = %"23", %"23" + unreachable + +"1848": ; preds = %"23" + unreachable + +"1849": ; preds = %"23" + unreachable + +"1851": ; preds = %"23" + unreachable + +"1853": ; preds = %"23" + unreachable + +"1856": ; preds = %"23" + unreachable + +"1861": ; preds = %"23", %"23" + unreachable + +"41": ; preds = %"23", %"23" + unreachable + +"1862": ; preds = %"1836", %"692" + unreachable +} From vhernandez at apple.com Mon Nov 9 12:29:14 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 9 Nov 2009 10:29:14 -0800 Subject: [llvm-commits] [llvm] r86525 - /llvm/trunk/lib/VMCore/Instructions.cpp In-Reply-To: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> References: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> Message-ID: <713246E4-FA50-4B27-AE69-2113326DF266@apple.com> Thanks for pointing this out, Duncan, and for fixing this, Chris. Victor On Nov 8, 2009, at 11:12 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Nov 9 01:12:01 2009 > New Revision: 86525 > > URL: http://llvm.org/viewvc/llvm-project?rev=86525&view=rev > Log: > make this handle redefinition of malloc with different prototype > correctly. > > Modified: > llvm/trunk/lib/VMCore/Instructions.cpp > > Modified: llvm/trunk/lib/VMCore/Instructions.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86525&r1=86524&r2=86525&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Instructions.cpp (original) > +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Nov 9 01:12:01 2009 > @@ -568,8 +568,7 @@ > const Type *VoidTy = Type::getVoidTy(M->getContext()); > const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); > // prototype free as "void free(void*)" > - Function *FreeFunc = cast(M->getOrInsertFunction > ("free", VoidTy, > - > IntPtrTy, NULL)); > + Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, > IntPtrTy, NULL); > CallInst* Result = NULL; > Value *PtrCast = Source; > if (InsertBefore) { > @@ -582,7 +581,8 @@ > Result = CallInst::Create(FreeFunc, PtrCast, ""); > } > Result->setTailCall(); > - Result->setCallingConv(FreeFunc->getCallingConv()); > + if (Function *F = dyn_cast(FreeFunc)) > + Result->setCallingConv(F->getCallingConv()); > > return Result; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Nov 9 12:40:39 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:40:39 -0000 Subject: [llvm-commits] [llvm] r86572 - /llvm/trunk/docs/LangRef.html Message-ID: <200911091840.nA9IedCK024858@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:40:39 2009 New Revision: 86572 URL: http://llvm.org/viewvc/llvm-project?rev=86572&view=rev Log: Remove the "special case" for zero-length arrays, and rephrase this paragraph to be more precise. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=86572&r1=86571&r2=86572&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Nov 9 12:40:39 2009 @@ -1576,12 +1576,13 @@ -

Note that 'variable sized arrays' can be implemented in LLVM with a zero - length array. Normally, accesses past the end of an array are undefined in - LLVM (e.g. it is illegal to access the 5th element of a 3 element array). As - a special case, however, zero length arrays are recognized to be variable - length. This allows implementation of 'pascal style arrays' with the LLVM - type "{ i32, [0 x float]}", for example.

+

Except when the inbounds keyword is present, there is no limitation + on indexing beyond the end of the array implied by the static type (though + any loads or stores must of course be within the bounds of the allocated + object!). This means that single-dimension 'variable sized array' addressing + can be implemented in LLVM with a zero length array type. An implementation + of 'pascal style arrays' in LLVM could use the type + "{ i32, [0 x float]}", for example.

Note that the code generator does not yet support large aggregate types to be used as function return types. The specific limit on how large an aggregate From baldrick at free.fr Mon Nov 9 12:49:54 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 19:49:54 +0100 Subject: [llvm-commits] [llvm] r86569 - in /llvm/trunk: lib/Transforms/Utils/LCSSA.cpp test/Transforms/LCSSA/indirectbr.ll In-Reply-To: <200911091828.nA9ISOw3024412@zion.cs.uiuc.edu> References: <200911091828.nA9ISOw3024412@zion.cs.uiuc.edu> Message-ID: <4AF86452.6080100@free.fr> Hi Dan, thanks for fixing this. > + // If the exit block has a predecessor not within the loop, arrange for > + // the incomging value use corresponding to that predecessor to be incomging -> incoming Ciao, Duncan. From baldrick at free.fr Mon Nov 9 12:52:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Nov 2009 19:52:12 +0100 Subject: [llvm-commits] [llvm] r86572 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200911091840.nA9IedCK024858@zion.cs.uiuc.edu> References: <200911091840.nA9IedCK024858@zion.cs.uiuc.edu> Message-ID: <4AF864DC.1050701@free.fr> Hi Dan, > +

Except when the inbounds keyword is present, there is no limitation > + on indexing beyond the end of the array implied by the static type (though > + any loads or stores must of course be within the bounds of the allocated > + object!). This means that single-dimension 'variable sized array' addressing > + can be implemented in LLVM with a zero length array type. An implementation > + of 'pascal style arrays' in LLVM could use the type > + "{ i32, [0 x float]}", for example.

does this mean that "inbounds" means that you are not allowed to index off the end of the *type*, even if you are not indexing off the end of the allocated object? Ciao, Duncan. From gohman at apple.com Mon Nov 9 12:59:22 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 18:59:22 -0000 Subject: [llvm-commits] [llvm] r86575 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Message-ID: <200911091859.nA9IxMhv025519@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 12:59:22 2009 New Revision: 86575 URL: http://llvm.org/viewvc/llvm-project?rev=86575&view=rev Log: Fix a comment in a typo that Duncan noticed. Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=86575&r1=86574&r2=86575&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Mon Nov 9 12:59:22 2009 @@ -235,7 +235,7 @@ PN->addIncoming(Inst, *PI); // If the exit block has a predecessor not within the loop, arrange for - // the incomging value use corresponding to that predecessor to be + // the incoming value use corresponding to that predecessor to be // rewritten in terms of a different LCSSA PHI. if (!inLoop(*PI)) UsesToRewrite.push_back( From gohman at apple.com Mon Nov 9 13:01:53 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 19:01:53 -0000 Subject: [llvm-commits] [llvm] r86576 - /llvm/trunk/docs/LangRef.html Message-ID: <200911091901.nA9J1rL2025650@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 13:01:53 2009 New Revision: 86576 URL: http://llvm.org/viewvc/llvm-project?rev=86576&view=rev Log: The inbounds keyword isn't relevant to overindexing of static array types. Thanks to Duncan for pointing this out! Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=86576&r1=86575&r2=86576&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Nov 9 13:01:53 2009 @@ -1576,13 +1576,12 @@ -

Except when the inbounds keyword is present, there is no limitation - on indexing beyond the end of the array implied by the static type (though - any loads or stores must of course be within the bounds of the allocated - object!). This means that single-dimension 'variable sized array' addressing - can be implemented in LLVM with a zero length array type. An implementation - of 'pascal style arrays' in LLVM could use the type - "{ i32, [0 x float]}", for example.

+

There is no restriction on indexing beyond the end of the array implied by + a static type (though there are restrictions on indexing beyond the bounds + of an allocated object in some cases). This means that single-dimension + 'variable sized array' addressing can be implemented in LLVM with a zero + length array type. An implementation of 'pascal style arrays' in LLVM could + use the type "{ i32, [0 x float]}", for example.

Note that the code generator does not yet support large aggregate types to be used as function return types. The specific limit on how large an aggregate From gohman at apple.com Mon Nov 9 13:03:12 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 9 Nov 2009 11:03:12 -0800 Subject: [llvm-commits] [llvm] r86572 - /llvm/trunk/docs/LangRef.html In-Reply-To: <4AF864DC.1050701@free.fr> References: <200911091840.nA9IedCK024858@zion.cs.uiuc.edu> <4AF864DC.1050701@free.fr> Message-ID: <9C55CAD3-EEF8-4F8F-A191-E1E14C99BAEC@apple.com> On Nov 9, 2009, at 10:52 AM, Duncan Sands wrote: > Hi Dan, > >> +

Except when the inbounds keyword is present, there is no limitation >> + on indexing beyond the end of the array implied by the static type (though >> + any loads or stores must of course be within the bounds of the allocated >> + object!). This means that single-dimension 'variable sized array' addressing >> + can be implemented in LLVM with a zero length array type. An implementation >> + of 'pascal style arrays' in LLVM could use the type >> + "{ i32, [0 x float]}", for example.

> > does this mean that "inbounds" means that you are not allowed to index off the > end of the *type*, even if you are not indexing off the end of the allocated > object? No; it means I made a mistake. Thanks! Dan From david_goodwin at apple.com Mon Nov 9 13:22:18 2009 From: david_goodwin at apple.com (David Goodwin) Date: Mon, 09 Nov 2009 19:22:18 -0000 Subject: [llvm-commits] [llvm] r86580 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <200911091922.nA9JMIKi026401@zion.cs.uiuc.edu> Author: david_goodwin Date: Mon Nov 9 13:22:17 2009 New Revision: 86580 URL: http://llvm.org/viewvc/llvm-project?rev=86580&view=rev Log: Fix dependencies added to model memory aliasing for post-RA scheduling. The dependencies were overly conservative for memory access that are known not to alias. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=86580&r1=86579&r2=86580&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Mon Nov 9 13:22:17 2009 @@ -112,12 +112,13 @@ V = getUnderlyingObject(V); if (const PseudoSourceValue *PSV = dyn_cast(V)) { - MayAlias = PSV->mayAlias(MFI); // For now, ignore PseudoSourceValues which may alias LLVM IR values // because the code that uses this function has no way to cope with // such aliases. if (PSV->isAliased(MFI)) return 0; + + MayAlias = PSV->mayAlias(MFI); return V; } @@ -127,23 +128,6 @@ return 0; } -static bool mayUnderlyingObjectForInstrAlias(const MachineInstr *MI, - const MachineFrameInfo *MFI) { - if (!MI->hasOneMemOperand() || - !(*MI->memoperands_begin())->getValue() || - (*MI->memoperands_begin())->isVolatile()) - return true; - - const Value *V = (*MI->memoperands_begin())->getValue(); - if (!V) - return true; - - V = getUnderlyingObject(V); - if (const PseudoSourceValue *PSV = dyn_cast(V)) - return PSV->mayAlias(MFI); - return true; -} - void ScheduleDAGInstrs::StartBlock(MachineBasicBlock *BB) { if (MachineLoop *ML = MLI.getLoopFor(BB)) if (BB == ML->getLoopLatch()) { @@ -163,16 +147,15 @@ // We build scheduling units by walking a block's instruction list from bottom // to top. - // Remember where a generic side-effecting instruction is as we procede. If - // ChainMMO is null, this is assumed to have arbitrary side-effects. If - // ChainMMO is non-null, then Chain makes only a single memory reference. - SUnit *Chain = 0; - MachineMemOperand *ChainMMO = 0; - - // Memory references to specific known memory locations are tracked so that - // they can be given more precise dependencies. - std::map MemDefs; - std::map > MemUses; + // Remember where a generic side-effecting instruction is as we procede. + SUnit *BarrierChain = 0, *AliasChain = 0; + + // Memory references to specific known memory locations are tracked + // so that they can be given more precise dependencies. We track + // separately the known memory locations that may alias and those + // that are known not to alias + std::map AliasMemDefs, NonAliasMemDefs; + std::map > AliasMemUses, NonAliasMemUses; // Check to see if the scheduler cares about latencies. bool UnitLatencies = ForceUnitLatencies(); @@ -347,114 +330,132 @@ // produce more precise dependence information. #define STORE_LOAD_LATENCY 1 unsigned TrueMemOrderLatency = 0; - if (TID.isCall() || TID.hasUnmodeledSideEffects()) { - new_chain: - // This is the conservative case. Add dependencies on all memory - // references. - if (Chain) - Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - Chain = SU; + if (TID.isCall() || TID.hasUnmodeledSideEffects() || + (MI->hasVolatileMemoryRef() && + (!TID.mayLoad() || !MI->isInvariantLoad(AA)))) { + // Be conservative with these and add dependencies on all memory + // references, even those that are known to not alias. + for (std::map::iterator I = + NonAliasMemDefs.begin(), E = NonAliasMemDefs.end(); I != E; ++I) { + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + } + for (std::map >::iterator I = + NonAliasMemUses.begin(), E = NonAliasMemUses.end(); I != E; ++I) { + for (unsigned i = 0, e = I->second.size(); i != e; ++i) + I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); + } + NonAliasMemDefs.clear(); + NonAliasMemUses.clear(); + // Add SU to the barrier chain. + if (BarrierChain) + BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + BarrierChain = SU; + + // fall-through + new_alias_chain: + // Chain all possibly aliasing memory references though SU. + if (AliasChain) + AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + AliasChain = SU; for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); - PendingLoads.clear(); - for (std::map::iterator I = MemDefs.begin(), - E = MemDefs.end(); I != E; ++I) { + for (std::map::iterator I = AliasMemDefs.begin(), + E = AliasMemDefs.end(); I != E; ++I) { I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - I->second = SU; } for (std::map >::iterator I = - MemUses.begin(), E = MemUses.end(); I != E; ++I) { + AliasMemUses.begin(), E = AliasMemUses.end(); I != E; ++I) { for (unsigned i = 0, e = I->second.size(); i != e; ++i) I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); - I->second.clear(); - I->second.push_back(SU); } - // See if it is known to just have a single memory reference. - MachineInstr *ChainMI = Chain->getInstr(); - const TargetInstrDesc &ChainTID = ChainMI->getDesc(); - if (!ChainTID.isCall() && - !ChainTID.hasUnmodeledSideEffects() && - ChainMI->hasOneMemOperand() && - !(*ChainMI->memoperands_begin())->isVolatile() && - (*ChainMI->memoperands_begin())->getValue()) - // We know that the Chain accesses one specific memory location. - ChainMMO = *ChainMI->memoperands_begin(); - else - // Unknown memory accesses. Assume the worst. - ChainMMO = 0; + PendingLoads.clear(); + AliasMemDefs.clear(); + AliasMemUses.clear(); } else if (TID.mayStore()) { bool MayAlias = true; TrueMemOrderLatency = STORE_LOAD_LATENCY; if (const Value *V = getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { // A store to a specific PseudoSourceValue. Add precise dependencies. - // Handle the def in MemDefs, if there is one. - std::map::iterator I = MemDefs.find(V); - if (I != MemDefs.end()) { + // Record the def in MemDefs, first adding a dep if there is + // an existing def. + std::map::iterator I = + ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V)); + std::map::iterator IE = + ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end()); + if (I != IE) { I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, /*isNormalMemory=*/true)); I->second = SU; } else { - MemDefs[V] = SU; + if (MayAlias) + AliasMemDefs[V] = SU; + else + NonAliasMemDefs[V] = SU; } // Handle the uses in MemUses, if there are any. std::map >::iterator J = - MemUses.find(V); - if (J != MemUses.end()) { + ((MayAlias) ? AliasMemUses.find(V) : NonAliasMemUses.find(V)); + std::map >::iterator JE = + ((MayAlias) ? AliasMemUses.end() : NonAliasMemUses.end()); + if (J != JE) { for (unsigned i = 0, e = J->second.size(); i != e; ++i) J->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency, /*Reg=*/0, /*isNormalMemory=*/true)); J->second.clear(); } if (MayAlias) { - // Add dependencies from all the PendingLoads, since without - // memoperands we must assume they alias anything. + // Add dependencies from all the PendingLoads, i.e. loads + // with no underlying object. for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); - // Add a general dependence too, if needed. - if (Chain) - Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + // Add dependence on alias chain, if needed. + if (AliasChain) + AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); } + // Add dependence on barrier chain, if needed. + if (BarrierChain) + BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); } else { // Treat all other stores conservatively. - goto new_chain; + goto new_alias_chain; } } else if (TID.mayLoad()) { bool MayAlias = true; TrueMemOrderLatency = 0; if (MI->isInvariantLoad(AA)) { // Invariant load, no chain dependencies needed! - } else if (const Value *V = - getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { - // A load from a specific PseudoSourceValue. Add precise dependencies. - std::map::iterator I = MemDefs.find(V); - if (I != MemDefs.end()) - I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, - /*isNormalMemory=*/true)); - MemUses[V].push_back(SU); - - // Add a general dependence too, if needed. - if (Chain && (!ChainMMO || - (ChainMMO->isStore() || ChainMMO->isVolatile()))) - Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - } else if (MI->hasVolatileMemoryRef()) { - // Treat volatile loads conservatively. Note that this includes - // cases where memoperand information is unavailable. - goto new_chain; } else { - // A "MayAlias" load. Depend on the general chain, as well as on - // all stores. In the absense of MachineMemOperand information, - // we can't even assume that the load doesn't alias well-behaved - // memory locations. - if (Chain) - Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - for (std::map::iterator I = MemDefs.begin(), - E = MemDefs.end(); I != E; ++I) { - SUnit *DefSU = I->second; - if (mayUnderlyingObjectForInstrAlias(DefSU->getInstr(), MFI)) - DefSU->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + if (const Value *V = + getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { + // A load from a specific PseudoSourceValue. Add precise dependencies. + std::map::iterator I = + ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V)); + std::map::iterator IE = + ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end()); + if (I != IE) + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, + /*isNormalMemory=*/true)); + if (MayAlias) + AliasMemUses[V].push_back(SU); + else + NonAliasMemUses[V].push_back(SU); + } else { + // A load with no underlying object. Depend on all + // potentially aliasing stores. + for (std::map::iterator I = + AliasMemDefs.begin(), E = AliasMemDefs.end(); I != E; ++I) + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + + PendingLoads.push_back(SU); + MayAlias = true; } - PendingLoads.push_back(SU); - } + + // Add dependencies on alias and barrier chains, if needed. + if (MayAlias && AliasChain) + AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + if (BarrierChain) + BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + } } } From gohman at apple.com Mon Nov 9 13:29:11 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 19:29:11 -0000 Subject: [llvm-commits] [llvm] r86582 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Transforms/GVN/null-aliases-nothing.ll Message-ID: <200911091929.nA9JTBHY026715@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 13:29:11 2009 New Revision: 86582 URL: http://llvm.org/viewvc/llvm-project?rev=86582&view=rev Log: Default-addressspace null pointers don't alias anything. This allows GVN to be more aggressive. Patch by Hans Wennborg! (with a comment added by me) Added: llvm/trunk/test/Transforms/GVN/null-aliases-nothing.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=86582&r1=86581&r2=86582&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Nov 9 13:29:11 2009 @@ -646,6 +646,15 @@ const Value *O1 = V1->getUnderlyingObject(); const Value *O2 = V2->getUnderlyingObject(); + // Null values in the default address space don't point to any object, so they + // don't alias any other pointer. + if (const ConstantPointerNull *CPN = dyn_cast(O1)) + if (CPN->getType()->getAddressSpace() == 0) + return NoAlias; + if (const ConstantPointerNull *CPN = dyn_cast(O2)) + if (CPN->getType()->getAddressSpace() == 0) + return NoAlias; + if (O1 != O2) { // If V1/V2 point to two different objects we know that we have no alias. if (isIdentifiedObject(O1) && isIdentifiedObject(O2)) Added: llvm/trunk/test/Transforms/GVN/null-aliases-nothing.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/null-aliases-nothing.ll?rev=86582&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/null-aliases-nothing.ll (added) +++ llvm/trunk/test/Transforms/GVN/null-aliases-nothing.ll Mon Nov 9 13:29:11 2009 @@ -0,0 +1,20 @@ +; RUN: opt %s -gvn -S | FileCheck %s + +%t = type { i32 } +declare void @test1f(i8*) + +define void @test1(%t* noalias %stuff ) { + %p = getelementptr inbounds %t* %stuff, i32 0, i32 0 + %before = load i32* %p + + call void @test1f(i8* null) + + %after = load i32* %p ; <--- This should be a dead load + %sum = add i32 %before, %after; + + store i32 %sum, i32* %p + ret void +; CHECK: load +; CHECK-NOT: load +; CHECK: ret void +} From clattner at apple.com Mon Nov 9 13:35:23 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Nov 2009 11:35:23 -0800 Subject: [llvm-commits] [llvm] r86569 - in /llvm/trunk: lib/Transforms/Utils/LCSSA.cpp test/Transforms/LCSSA/indirectbr.ll In-Reply-To: <200911091828.nA9ISOw3024412@zion.cs.uiuc.edu> References: <200911091828.nA9ISOw3024412@zion.cs.uiuc.edu> Message-ID: <7D50C282-1343-4BAA-BF50-5CDF6207E6AD@apple.com> On Nov 9, 2009, at 10:28 AM, Dan Gohman wrote: > Author: djg > Date: Mon Nov 9 12:28:24 2009 > New Revision: 86569 > > URL: http://llvm.org/viewvc/llvm-project?rev=86569&view=rev > Log: > Generalize LCSSA to handle loops with exits with predecessors outside > the loop. This is needed because with indirectbr it may not be > possible > for LoopSimplify to guarantee that all loop exit predecessors are > inside the loop. This fixes PR5437. > > LCCSA no longer actually requires LoopSimplify form, but for now it > must still have the dependency because the PassManager doesn't know > how to schedule LoopSimplify otherwise. Dan, can you please manually shrink the testcase? -Chris From gohman at apple.com Mon Nov 9 13:38:46 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 19:38:46 -0000 Subject: [llvm-commits] [llvm] r86583 - in /llvm/trunk: include/llvm/CodeGen/MachineRegisterInfo.h lib/CodeGen/MachineInstr.cpp Message-ID: <200911091938.nA9Jck7i027097@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 13:38:45 2009 New Revision: 86583 URL: http://llvm.org/viewvc/llvm-project?rev=86583&view=rev Log: Print "..." instead of all the uninteresting register clobbers on call instructions. This makes CodeGen dumps significantly less noisy. Example before: BL , %R0, %R1, %R2, %R3, %R12, %LR, %D0, %D1, %D2, %D3, %D4, %D5, %D6, %D7, %D16, %D17, %D18, %D19, %D20, %D21, %D22, %D23, %D24, %D25, %D26, %D27, %D28, %D29, %D30, %D31, %CPSR, %FPSCR Same example after: BL , %R0, %R1, %LR, %CPSR, ... Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=86583&r1=86582&r2=86583&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Nov 9 13:38:45 2009 @@ -243,6 +243,12 @@ return true; return false; } + bool isLiveOut(unsigned Reg) const { + for (liveout_iterator I = liveout_begin(), E = liveout_end(); I != E; ++I) + if (*I == Reg) + return true; + return false; + } private: void HandleVRegListReallocation(); Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=86583&r1=86582&r2=86583&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Nov 9 13:38:45 2009 @@ -189,19 +189,19 @@ /// print - Print the specified machine operand. /// void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const { + // If the instruction is embedded into a basic block, we can find the + // target info for the instruction. + if (!TM) + if (const MachineInstr *MI = getParent()) + if (const MachineBasicBlock *MBB = MI->getParent()) + if (const MachineFunction *MF = MBB->getParent()) + TM = &MF->getTarget(); + switch (getType()) { case MachineOperand::MO_Register: if (getReg() == 0 || TargetRegisterInfo::isVirtualRegister(getReg())) { OS << "%reg" << getReg(); } else { - // If the instruction is embedded into a basic block, we can find the - // target info for the instruction. - if (TM == 0) - if (const MachineInstr *MI = getParent()) - if (const MachineBasicBlock *MBB = MI->getParent()) - if (const MachineFunction *MF = MBB->getParent()) - TM = &MF->getTarget(); - if (TM) OS << "%" << TM->getRegisterInfo()->get(getReg()).Name; else @@ -1061,9 +1061,16 @@ } void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const { - unsigned StartOp = 0, e = getNumOperands(); + // We can be a bit tidier if we know the TargetMachine and/or MachineFunction. + const MachineFunction *MF = 0; + if (const MachineBasicBlock *MBB = getParent()) { + MF = MBB->getParent(); + if (!TM && MF) + TM = &MF->getTarget(); + } // Print explicitly defined operands on the left of an assignment syntax. + unsigned StartOp = 0, e = getNumOperands(); for (; StartOp < e && getOperand(StartOp).isReg() && getOperand(StartOp).isDef() && !getOperand(StartOp).isImplicit(); @@ -1079,11 +1086,45 @@ OS << getDesc().getName(); // Print the rest of the operands. + bool OmittedAnyCallClobbers = false; + bool FirstOp = true; for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) { - if (i != StartOp) - OS << ","; + const MachineOperand &MO = getOperand(i); + + // Omit call-clobbered registers which aren't used anywhere. This makes + // call instructions much less noisy on targets where calls clobber lots + // of registers. Don't rely on MO.isDead() because we may be called before + // LiveVariables is run, or we may be looking at a non-allocatable reg. + if (MF && getDesc().isCall() && + MO.isReg() && MO.isImplicit() && MO.isDef()) { + unsigned Reg = MO.getReg(); + if (Reg != 0 && TargetRegisterInfo::isPhysicalRegister(Reg)) { + const MachineRegisterInfo &MRI = MF->getRegInfo(); + if (MRI.use_empty(Reg) && !MRI.isLiveOut(Reg)) { + bool HasAliasLive = false; + for (const unsigned *Alias = TM->getRegisterInfo()->getAliasSet(Reg); + unsigned AliasReg = *Alias; ++Alias) + if (!MRI.use_empty(AliasReg) || MRI.isLiveOut(AliasReg)) { + HasAliasLive = true; + break; + } + if (!HasAliasLive) { + OmittedAnyCallClobbers = true; + continue; + } + } + } + } + + if (FirstOp) FirstOp = false; else OS << ","; OS << " "; - getOperand(i).print(OS, TM); + MO.print(OS, TM); + } + + // Briefly indicate whether any call clobbers were omitted. + if (OmittedAnyCallClobbers) { + if (FirstOp) FirstOp = false; else OS << ","; + OS << " ..."; } bool HaveSemi = false; @@ -1099,12 +1140,11 @@ } } - if (!debugLoc.isUnknown()) { + if (!debugLoc.isUnknown() && MF) { if (!HaveSemi) OS << ";"; HaveSemi = true; // TODO: print InlinedAtLoc information - const MachineFunction *MF = getParent()->getParent(); DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); DICompileUnit CU(DLT.Scope); if (!CU.isNull()) From deeppatel1987 at gmail.com Mon Nov 9 14:42:29 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Mon, 9 Nov 2009 20:42:29 +0000 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> Message-ID: <305d6f60911091242p3c122cadqc9baf8c477799696@mail.gmail.com> On Mon, Nov 9, 2009 at 2:37 AM, Kenneth Uildriks wrote: > If a struct can't be returned in registers, have SelectionDAGBuild > insert a hidden sret parameter and have return instructions store the > return value through the hidden pointer. ?Formal arguments, return > instructions, and calls are all updated as needed. > > Only x86 has the code to actually check whether sret-demotion is > needed.... other platforms invariably report that they can return > values in registers, even when they can't. There is definitely an ABI issue here. For ARM AAPCS-VFP, we need to decide that a aggregate is to be passed in registers based on information like unions which aren't represented in the LLVM IR. Perhaps I've missed the overall goal. If the CC is "fast" then this sort of thing makes a lot of sense, but "C" and other CCs need to be established by the front-end and not perturbed by the backend. deep From kennethuil at gmail.com Mon Nov 9 14:59:09 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 9 Nov 2009 14:59:09 -0600 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <305d6f60911091242p3c122cadqc9baf8c477799696@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <305d6f60911091242p3c122cadqc9baf8c477799696@mail.gmail.com> Message-ID: <400d33ea0911091259t1b72e66ejd55129973916b57c@mail.gmail.com> On Mon, Nov 9, 2009 at 2:42 PM, Sandeep Patel wrote: > On Mon, Nov 9, 2009 at 2:37 AM, Kenneth Uildriks wrote: >> If a struct can't be returned in registers, have SelectionDAGBuild >> insert a hidden sret parameter and have return instructions store the >> return value through the hidden pointer. ?Formal arguments, return >> instructions, and calls are all updated as needed. >> >> Only x86 has the code to actually check whether sret-demotion is >> needed.... other platforms invariably report that they can return >> values in registers, even when they can't. > > There is definitely an ABI issue here. For ARM AAPCS-VFP, we need to > decide that a aggregate is to be passed in registers based on > information like unions which aren't represented in the LLVM IR. > > Perhaps I've missed the overall goal. If the CC is "fast" then this > sort of thing makes a lot of sense, but "C" and other CCs need to be > established by the front-end and not perturbed by the backend. > > deep > The trouble is that the front-end doesn't have enough information. You need to get all the way to the SelectionDAG before you can even begin to determine whether the target/calling convention combo is capable of returning your struct in registers... and if it isn't, SelectionDAG falls over and dies when it hits the function. So you can't guarantee while building your IR that SelectionDAG won't abort (unless you hardcode target-specific rules into your front-end). This transformation will only kick in in cases where the present version falls over and dies. Existing, working code will behave no differently. Existing target-specific front-ends will not be affected. From gohman at apple.com Mon Nov 9 15:14:46 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 9 Nov 2009 13:14:46 -0800 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> Message-ID: <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> On Nov 8, 2009, at 6:37 PM, Kenneth Uildriks wrote: > If a struct can't be returned in registers, have SelectionDAGBuild > insert a hidden sret parameter and have return instructions store the > return value through the hidden pointer. Formal arguments, return > instructions, and calls are all updated as needed. > > Only x86 has the code to actually check whether sret-demotion is > needed.... other platforms invariably report that they can return > values in registers, even when they can't. Hello, Overall this patch looks good. Thanks for working on this! I have a few comments. > + // True if the function needs to be sret-demoted > + bool CantLowerReturn; > > + // Virtual register to hold the sret pointer for sret-demotion > + unsigned DemoteRegister; Would it be possible to put this field in FunctionLoweringInfo instead of MachineFunction? It's information that's only really relevant during lowering to the SelectionDAG. > - if (F->paramHasAttr(0, Attribute::SExt)) > - ExtendKind = ISD::SIGN_EXTEND; > - else if (F->paramHasAttr(0, Attribute::ZExt)) > - ExtendKind = ISD::ZERO_EXTEND; I'm unclear on why this code is being removed. Can you explain what's happening here? > + if (!CanLowerReturn) > + { In general, LLVM style has the opening brace on the same line as the if, else, for, etc. Dan From isanbard at gmail.com Mon Nov 9 15:20:14 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 09 Nov 2009 21:20:14 -0000 Subject: [llvm-commits] [llvm] r86588 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <200911092120.nA9LKEul031824@zion.cs.uiuc.edu> Author: void Date: Mon Nov 9 15:20:14 2009 New Revision: 86588 URL: http://llvm.org/viewvc/llvm-project?rev=86588&view=rev Log: The jump table was being generated before the end label for exception handling was generated. This caused code like this: ## The asm code for the function .section __TEXT,__const .align 2 lJTI11_0: LJTI11_0: .long LBB11_16 .long LBB11_4 .long LBB11_5 .long LBB11_6 .long LBB11_7 .long LBB11_8 .long LBB11_9 .long LBB11_10 .long LBB11_11 .long LBB11_12 .long LBB11_13 .long LBB11_14 Leh_func_end11: ## <---now in the wrong section! The `Leh_func_end11' would then end up in the wrong section, causing the resulting EH frame information to be wrong: __ZL11CheckRightsjPKcbRbRP6NSData.eh: .set Lset500eh,Leh_frame_end11-Leh_frame_begin11 .long Lset500eh ; Length of Frame Information Entry Leh_frame_begin11: .long Leh_frame_begin11-Leh_frame_common .long Leh_func_begin11-. .set Lset501eh,Leh_func_end11-Leh_func_begin11 .long Lset501eh ; FDE address range `Lset501eh' is now something huge instead of the real value. The X86 back-end generates the jump table after the EH information is emitted. Do the same here. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=86588&r1=86587&r2=86588&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Mon Nov 9 15:20:14 2009 @@ -672,14 +672,14 @@ O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << '\n'; - // Print out jump tables referenced by the function. - EmitJumpTableInfo(MF.getJumpTableInfo(), MF); - OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); // Emit post-function debug information. DW->EndFunction(&MF); + // Print out jump tables referenced by the function. + EmitJumpTableInfo(MF.getJumpTableInfo(), MF); + // We didn't modify anything. return false; } From kennethuil at gmail.com Mon Nov 9 15:43:02 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 9 Nov 2009 15:43:02 -0600 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> Message-ID: <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> On Mon, Nov 9, 2009 at 3:14 PM, Dan Gohman wrote: > > On Nov 8, 2009, at 6:37 PM, Kenneth Uildriks wrote: > >> If a struct can't be returned in registers, have SelectionDAGBuild >> insert a hidden sret parameter and have return instructions store the >> return value through the hidden pointer. ?Formal arguments, return >> instructions, and calls are all updated as needed. >> >> Only x86 has the code to actually check whether sret-demotion is >> needed.... other platforms invariably report that they can return >> values in registers, even when they can't. > > Hello, > > Overall this patch looks good. Thanks for working on this! I > have a few comments. > >> + ?// True if the function needs to be sret-demoted >> + ?bool CantLowerReturn; >> >> + ?// Virtual register to hold the sret pointer for sret-demotion >> + ?unsigned DemoteRegister; > > Would it be possible to put this field in FunctionLoweringInfo > instead of MachineFunction? It's information that's only really > relevant during lowering to the SelectionDAG. Thanks for pointing that out... I found code in SelectionDAGBuild that pulls the FunctionLoweringInfo from the DAG. Assuming I always get the same instance back for the same function, it should be pretty easy. > >> - ? ?if (F->paramHasAttr(0, Attribute::SExt)) >> - ? ? ?ExtendKind = ISD::SIGN_EXTEND; >> - ? ?else if (F->paramHasAttr(0, Attribute::ZExt)) >> - ? ? ?ExtendKind = ISD::ZERO_EXTEND; > > I'm unclear on why this code is being removed. Can you explain > what's happening here? I was assuming that the attributes only appeared on int return values, not struct return values. However, "getReturnInfo" is declared to be more general than the use to which I'm currently putting it, and that if it's called with an int return type without the attribute, it'll return the wrong EVT for it. I'll put them back in and pass the flags for those attributes. > >> + ?if (!CanLowerReturn) >> + ?{ > > In general, LLVM style has the opening brace on the same line as the > if, else, for, etc. > > Dan > > Whoops. From isanbard at gmail.com Mon Nov 9 15:45:26 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 09 Nov 2009 21:45:26 -0000 Subject: [llvm-commits] [llvm] r86592 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <200911092145.nA9LjR6h000359@zion.cs.uiuc.edu> Author: void Date: Mon Nov 9 15:45:26 2009 New Revision: 86592 URL: http://llvm.org/viewvc/llvm-project?rev=86592&view=rev Log: Similar to r86588, but for Darwin this time. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=86592&r1=86591&r2=86592&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Mon Nov 9 15:45:26 2009 @@ -853,12 +853,12 @@ } } - // Print out jump tables referenced by the function. - EmitJumpTableInfo(MF.getJumpTableInfo(), MF); - // Emit post-function debug information. DW->EndFunction(&MF); + // Print out jump tables referenced by the function. + EmitJumpTableInfo(MF.getJumpTableInfo(), MF); + // We didn't modify anything. return false; } From mrs at apple.com Mon Nov 9 16:28:21 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 09 Nov 2009 22:28:21 -0000 Subject: [llvm-commits] [llvm] r86600 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200911092228.nA9MSLFw002262@zion.cs.uiuc.edu> Author: mrs Date: Mon Nov 9 16:28:21 2009 New Revision: 86600 URL: http://llvm.org/viewvc/llvm-project?rev=86600&view=rev Log: Fix for 64-bit builds. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86600&r1=86599&r2=86600&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Nov 9 16:28:21 2009 @@ -4287,7 +4287,7 @@ EVT Ty = Arg.getValueType(); if (CI->getZExtValue() < 2) - setValue(&I, DAG.getConstant(-1U, Ty)); + setValue(&I, DAG.getConstant(-1ULL, Ty)); else setValue(&I, DAG.getConstant(0, Ty)); return 0; From gohman at apple.com Mon Nov 9 16:28:30 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 22:28:30 -0000 Subject: [llvm-commits] [llvm] r86601 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200911092228.nA9MSUOi002281@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 16:28:30 2009 New Revision: 86601 URL: http://llvm.org/viewvc/llvm-project?rev=86601&view=rev Log: Remove an unneeded #include. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=86601&r1=86600&r2=86601&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Nov 9 16:28:30 2009 @@ -37,7 +37,6 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include -#include using namespace llvm; STATISTIC(NodesCombined , "Number of dag nodes combined"); From echristo at apple.com Mon Nov 9 16:29:14 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 9 Nov 2009 14:29:14 -0800 Subject: [llvm-commits] [llvm] r86600 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <200911092228.nA9MSLFw002262@zion.cs.uiuc.edu> References: <200911092228.nA9MSLFw002262@zion.cs.uiuc.edu> Message-ID: <6D81D7E0-1A25-4A71-99DE-685A7096A4A5@apple.com> On Nov 9, 2009, at 2:28 PM, Mike Stump wrote: > Author: mrs > Date: Mon Nov 9 16:28:21 2009 > New Revision: 86600 > > URL: http://llvm.org/viewvc/llvm-project?rev=86600&view=rev > Log: > Fix for 64-bit builds. Thanks. Guess that did work :) Please throw a testcase in somewhere to make sure I don't break it. -eric From grosbach at apple.com Mon Nov 9 16:32:03 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 Nov 2009 22:32:03 -0000 Subject: [llvm-commits] [llvm] r86602 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911092232.nA9MW3EK002529@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 9 16:32:03 2009 New Revision: 86602 URL: http://llvm.org/viewvc/llvm-project?rev=86602&view=rev Log: Set dynamic stack realignment to real values. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86602&r1=86601&r2=86602&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Nov 9 16:32:03 2009 @@ -476,11 +476,7 @@ } static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) { - // FIXME: For now, force at least 128-bit alignment. This will push the - // nightly tester harder for making sure things work correctly. When - // we're ready to enable this for real, this goes back to starting at zero. - unsigned MaxAlign = 16; -// unsigned MaxAlign = 0; + unsigned MaxAlign = 0; for (int i = FFI->getObjectIndexBegin(), e = FFI->getObjectIndexEnd(); i != e; ++i) { @@ -508,19 +504,15 @@ bool ARMBaseRegisterInfo:: needsStackRealignment(const MachineFunction &MF) const { - // Only do this for ARM if explicitly enabled - // FIXME: Once it's passing all the tests, enable by default if (!ARMDynamicStackAlign) return false; - // FIXME: To force more brutal testing, realign whether we need to or not. - // Change this to be more selective when we turn it on for real, of course. const MachineFrameInfo *MFI = MF.getFrameInfo(); const ARMFunctionInfo *AFI = MF.getInfo(); -// unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); return (RealignStack && !AFI->isThumb1OnlyFunction() && -// (MFI->getMaxAlignment() > StackAlign) && + (MFI->getMaxAlignment() > StackAlign) && !MFI->hasVarSizedObjects()); } From sabre at nondot.org Mon Nov 9 16:32:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 22:32:37 -0000 Subject: [llvm-commits] [llvm] r86603 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911092232.nA9MWbu6002598@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 16:32:36 2009 New Revision: 86603 URL: http://llvm.org/viewvc/llvm-project?rev=86603&view=rev Log: stub out a new form of BasicBlock::RemovePredecessorAndSimplify which simplifies instruction users of PHIs when the phi is eliminated. This will be moved to transforms/utils after some other refactoring. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86603&r1=86602&r2=86603&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 16:32:36 2009 @@ -180,6 +180,68 @@ } +//===----------------------------------------------------------------------===// + + +/// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this +/// method is called when we're about to delete Pred as a predecessor of BB. If +/// BB contains any PHI nodes, this drops the entries in the PHI nodes for Pred. +/// +/// Unlike the removePredecessor method, this attempts to simplify uses of PHI +/// nodes that collapse into identity values. For example, if we have: +/// x = phi(1, 0, 0, 0) +/// y = and x, z +/// +/// .. and delete the predecessor corresponding to the '1', this will attempt to +/// recursively fold the and to 0. +static void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, + TargetData *TD) { + // This only adjusts blocks with PHI nodes. + if (!isa(BB->begin())) + return; + + // Remove the entries for Pred from the PHI nodes in BB, but do not simplify + // them down. This will leave us with single entry phi nodes and other phis + // that can be removed. + //BB->removePredecessor(Pred, true); + BB->removePredecessor(Pred, true); + + WeakVH PhiIt = &BB->front(); + while (PHINode *PN = dyn_cast(PhiIt)) { + PhiIt = &*++BasicBlock::iterator(cast(PhiIt)); + + Value *PNV = PN->hasConstantValue(); + if (PNV == 0) continue; + + assert(PNV != PN && "hasConstantValue broken"); + + // If we're able to simplify the phi to a constant, simplify it into its + // uses. + while (!PN->use_empty()) { + // Update the instruction to use the new value. + Use &U = PN->use_begin().getUse(); + Instruction *User = cast(U.getUser()); + U = PNV; + + // See if we can simplify it (constant folding). + if (Constant *C = ConstantFoldInstruction(User, TD)) { + User->replaceAllUsesWith(C); + User->eraseFromParent(); + } + } + + PN->replaceAllUsesWith(PNV); + PN->eraseFromParent(); + + // If recursive simplification ended up deleting the next PHI node we would + // iterate to, then our iterator is invalid, restart scanning from the top + // of the block. + if (PhiIt == 0) PhiIt = &BB->front(); + } +} + +//===----------------------------------------------------------------------===// + /// FindLoopHeaders - We do not want jump threading to turn proper loop /// structures into irreducible loops. Doing this breaks up the loop nesting @@ -411,7 +473,7 @@ TerminatorInst *BBTerm = BB->getTerminator(); for (unsigned i = 0, e = BBTerm->getNumSuccessors(); i != e; ++i) { if (i == BestSucc) continue; - BBTerm->getSuccessor(i)->removePredecessor(BB); + RemovePredecessorAndSimplify(BBTerm->getSuccessor(i), BB, TD); } DEBUG(errs() << " In block '" << BB->getName() @@ -868,8 +930,6 @@ if (LoopHeaders.count(BB)) return false; - - SmallVector, 8> PredValues; if (!ComputeValueKnownInPredecessors(CondInst, BB, PredValues)) return false; @@ -1153,7 +1213,7 @@ TerminatorInst *PredTerm = PredBB->getTerminator(); for (unsigned i = 0, e = PredTerm->getNumSuccessors(); i != e; ++i) if (PredTerm->getSuccessor(i) == BB) { - BB->removePredecessor(PredBB); + RemovePredecessorAndSimplify(BB, PredBB, TD); PredTerm->setSuccessor(i, NewBB); } @@ -1283,7 +1343,7 @@ // PredBB no longer jumps to BB, remove entries in the PHI node for the edge // that we nuked. - BB->removePredecessor(PredBB); + RemovePredecessorAndSimplify(BB, PredBB, TD); // Remove the unconditional branch at the end of the PredBB block. OldPredBranch->eraseFromParent(); From grosbach at apple.com Mon Nov 9 16:32:40 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 Nov 2009 22:32:40 -0000 Subject: [llvm-commits] [llvm] r86604 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911092232.nA9MWeAk002613@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 9 16:32:40 2009 New Revision: 86604 URL: http://llvm.org/viewvc/llvm-project?rev=86604&view=rev Log: Enable dynamic stack realignment by default. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86604&r1=86603&r2=86604&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Nov 9 16:32:40 2009 @@ -45,7 +45,7 @@ cl::desc("Reuse repeated frame index values")); static cl::opt -ARMDynamicStackAlign("arm-dynamic-stack-alignment", cl::Hidden, cl::init(false), +ARMDynamicStackAlign("arm-dynamic-stack-alignment", cl::Hidden, cl::init(true), cl::desc("Dynamically re-align the stack as needed")); unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum, From jyasskin at google.com Mon Nov 9 16:34:19 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 09 Nov 2009 22:34:19 -0000 Subject: [llvm-commits] [llvm] r86606 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h include/llvm/ExecutionEngine/JITMemoryManager.h lib/ExecutionEngine/ExecutionEngine.cpp lib/ExecutionEngine/JIT/JIT.cpp lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/JIT/JITEmitter.cpp lib/ExecutionEngine/JIT/JITMemoryManager.cpp unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200911092234.nA9MYKSQ002783@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Nov 9 16:34:19 2009 New Revision: 86606 URL: http://llvm.org/viewvc/llvm-project?rev=86606&view=rev Log: Remove dlsym stubs, with Nate Begeman's permission. Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.h llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Mon Nov 9 16:34:19 2009 @@ -91,7 +91,6 @@ bool CompilingLazily; bool GVCompilationDisabled; bool SymbolSearchingDisabled; - bool DlsymStubsEnabled; friend class EngineBuilder; // To allow access to JITCtor and InterpCtor. @@ -369,15 +368,7 @@ bool isSymbolSearchingDisabled() const { return SymbolSearchingDisabled; } - - /// EnableDlsymStubs - - void EnableDlsymStubs(bool Enabled = true) { - DlsymStubsEnabled = Enabled; - } - bool areDlsymStubsEnabled() const { - return DlsymStubsEnabled; - } - + /// InstallLazyFunctionCreator - If an unknown function is needed, the /// specified function pointer is invoked to create it. If it returns null, /// the JIT will abort. Modified: llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h Mon Nov 9 16:34:19 2009 @@ -71,17 +71,6 @@ /// return a pointer to its base. virtual uint8_t *getGOTBase() const = 0; - /// SetDlsymTable - If the JIT must be able to relocate stubs after they have - /// been emitted, potentially because they are being copied to a process - /// where external symbols live at different addresses than in the JITing - /// process, allocate a table with sufficient information to do so. - virtual void SetDlsymTable(void *ptr) = 0; - - /// getDlsymTable - If this is managing a table of entries so that stubs to - /// external symbols can be later relocated, this method should return a - /// pointer to it. - virtual void *getDlsymTable() const = 0; - /// NeedsExactSize - If the memory manager requires to know the size of the /// objects to be emitted bool NeedsExactSize() const { Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Mon Nov 9 16:34:19 2009 @@ -52,7 +52,6 @@ CompilingLazily = false; GVCompilationDisabled = false; SymbolSearchingDisabled = false; - DlsymStubsEnabled = false; Modules.push_back(P); assert(P && "ModuleProvider is null?"); } Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Mon Nov 9 16:34:19 2009 @@ -613,11 +613,6 @@ // the stub with real address of the function. updateFunctionStub(PF); } - - // If the JIT is configured to emit info so that dlsym can be used to - // rewrite stubs to external globals, do so now. - if (areDlsymStubsEnabled() && !isCompilingLazily()) - updateDlsymStubTable(); } /// getPointerToFunction - This method is used to get the address of the @@ -660,8 +655,7 @@ } if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) { - bool AbortOnFailure = - !areDlsymStubsEnabled() && !F->hasExternalWeakLinkage(); + bool AbortOnFailure = !F->hasExternalWeakLinkage(); void *Addr = getPointerToNamedFunction(F->getName(), AbortOnFailure); addGlobalMapping(F, Addr); return Addr; @@ -690,7 +684,7 @@ return (void*)&__dso_handle; #endif Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(GV->getName()); - if (Ptr == 0 && !areDlsymStubsEnabled()) { + if (Ptr == 0) { llvm_report_error("Could not resolve external global address: " +GV->getName()); } Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Mon Nov 9 16:34:19 2009 @@ -195,7 +195,6 @@ TargetMachine &tm); void runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked); void updateFunctionStub(Function *F); - void updateDlsymStubTable(); protected: Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Nov 9 16:34:19 2009 @@ -369,10 +369,6 @@ // the stub is unused. DenseMap > StubFnRefs; - // ExtFnStubs - A map of external function names to stubs which have entries - // in the JITResolver's ExternalFnToStubMap. - StringMap ExtFnStubs; - DebugLocTuple PrevDLT; public: @@ -461,10 +457,6 @@ /// deallocateMemForFunction to also remove stubs no longer referenced. void AddStubToCurrentFunction(void *Stub); - /// getExternalFnStubs - Accessor for the JIT to find stubs emitted for - /// MachineRelocations that reference external functions by name. - const StringMap &getExternalFnStubs() const { return ExtFnStubs; } - virtual void processDebugLoc(DebugLoc DL, bool BeforePrintingInsn); virtual void emitLabel(uint64_t LabelID) { @@ -536,10 +528,8 @@ Actual = TheJIT->getPointerToFunction(F); // If we resolved the symbol to a null address (eg. a weak external) - // don't emit a stub. Return a null pointer to the application. If dlsym - // stubs are enabled, not being able to resolve the address is not - // meaningful. - if (!Actual && !TheJIT->areDlsymStubsEnabled()) return 0; + // don't emit a stub. Return a null pointer to the application. + if (!Actual) return 0; } // Codegen a new stub, calling the lazy resolver or the actual address of the @@ -758,10 +748,9 @@ if (ResultPtr) return ResultPtr; // If this is an external function pointer, we can force the JIT to - // 'compile' it, which really just adds it to the map. In dlsym mode, - // external functions are forced through a stub, regardless of reloc type. + // 'compile' it, which really just adds it to the map. if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode() && - !MayNeedFarStub && !TheJIT->areDlsymStubsEnabled()) + !MayNeedFarStub) return TheJIT->getPointerToFunction(F); // Okay, the function has not been compiled yet, if the target callback @@ -1112,16 +1101,7 @@ // If the target REALLY wants a stub for this function, emit it now. if (MR.mayNeedFarStub()) { - if (!TheJIT->areDlsymStubsEnabled()) { - ResultPtr = Resolver.getExternalFunctionStub(ResultPtr); - } else { - void *&Stub = ExtFnStubs[MR.getExternalSymbol()]; - if (!Stub) { - Stub = Resolver.getExternalFunctionStub((void *)&Stub); - AddStubToCurrentFunction(Stub); - } - ResultPtr = Stub; - } + ResultPtr = Resolver.getExternalFunctionStub(ResultPtr); } } else if (MR.isGlobalValue()) { ResultPtr = getPointerToGlobal(MR.getGlobalValue(), @@ -1335,19 +1315,10 @@ StubFnRefs.erase(Stub); // Invalidate the stub. If it is a GV stub, update the JIT's global - // mapping for that GV to zero, otherwise, search the string map of - // external function names to stubs and remove the entry for this stub. + // mapping for that GV to zero. GlobalValue *GV = Resolver.invalidateStub(Stub); if (GV) { TheJIT->updateGlobalMapping(GV, 0); - } else { - for (StringMapIterator i = ExtFnStubs.begin(), - e = ExtFnStubs.end(); i != e; ++i) { - if (i->second == Stub) { - ExtFnStubs.erase(i); - break; - } - } } } } @@ -1588,92 +1559,6 @@ getJITInfo().emitFunctionStubAtAddr(F, Addr, Stub, *getCodeEmitter()); } -/// updateDlsymStubTable - Emit the data necessary to relocate the stubs -/// that were emitted during code generation. -/// -void JIT::updateDlsymStubTable() { - assert(isa(JCE) && "Unexpected MCE?"); - JITEmitter *JE = cast(getCodeEmitter()); - - SmallVector GVs; - SmallVector Ptrs; - const StringMap &ExtFns = JE->getExternalFnStubs(); - - JE->getJITResolver().getRelocatableGVs(GVs, Ptrs); - - unsigned nStubs = GVs.size() + ExtFns.size(); - - // If there are no relocatable stubs, return. - if (nStubs == 0) - return; - - // If there are no new relocatable stubs, return. - void *CurTable = JE->getMemMgr()->getDlsymTable(); - if (CurTable && (*(unsigned *)CurTable == nStubs)) - return; - - // Calculate the size of the stub info - unsigned offset = 4 + 4 * nStubs + sizeof(intptr_t) * nStubs; - - SmallVector Offsets; - for (unsigned i = 0; i != GVs.size(); ++i) { - Offsets.push_back(offset); - offset += GVs[i]->getName().size() + 1; - } - for (StringMapConstIterator i = ExtFns.begin(), e = ExtFns.end(); - i != e; ++i) { - Offsets.push_back(offset); - offset += strlen(i->first()) + 1; - } - - // Allocate space for the new "stub", which contains the dlsym table. - JE->startGVStub(0, offset, 4); - - // Emit the number of records - JE->emitInt32(nStubs); - - // Emit the string offsets - for (unsigned i = 0; i != nStubs; ++i) - JE->emitInt32(Offsets[i]); - - // Emit the pointers. Verify that they are at least 2-byte aligned, and set - // the low bit to 0 == GV, 1 == Function, so that the client code doing the - // relocation can write the relocated pointer at the appropriate place in - // the stub. - for (unsigned i = 0; i != GVs.size(); ++i) { - intptr_t Ptr = (intptr_t)Ptrs[i]; - assert((Ptr & 1) == 0 && "Stub pointers must be at least 2-byte aligned!"); - - if (isa(GVs[i])) - Ptr |= (intptr_t)1; - - if (sizeof(Ptr) == 8) - JE->emitInt64(Ptr); - else - JE->emitInt32(Ptr); - } - for (StringMapConstIterator i = ExtFns.begin(), e = ExtFns.end(); - i != e; ++i) { - intptr_t Ptr = (intptr_t)i->second | 1; - - if (sizeof(Ptr) == 8) - JE->emitInt64(Ptr); - else - JE->emitInt32(Ptr); - } - - // Emit the strings. - for (unsigned i = 0; i != GVs.size(); ++i) - JE->emitString(GVs[i]->getName()); - for (StringMapConstIterator i = ExtFns.begin(), e = ExtFns.end(); - i != e; ++i) - JE->emitString(i->first()); - - // Tell the JIT memory manager where it is. The JIT Memory Manager will - // deallocate space for the old one, if one existed. - JE->getMemMgr()->SetDlsymTable(JE->finishGVStub(0)); -} - /// freeMachineCodeForFunction - release machine code memory for given Function. /// void JIT::freeMachineCodeForFunction(Function *F) { Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Mon Nov 9 16:34:19 2009 @@ -296,7 +296,6 @@ MemoryRangeHeader *CurBlock; uint8_t *GOTBase; // Target Specific reserved memory - void *DlsymTable; // Stub external symbol information public: DefaultJITMemoryManager(); ~DefaultJITMemoryManager(); @@ -318,7 +317,6 @@ static const size_t DefaultSizeThreshold; void AllocateGOT(); - void SetDlsymTable(void *); // Testing methods. virtual bool CheckInvariants(std::string &ErrorStr); @@ -469,10 +467,6 @@ return GOTBase; } - void *getDlsymTable() const { - return DlsymTable; - } - void deallocateBlock(void *Block) { // Find the block that is allocated for this function. MemoryRangeHeader *MemRange = static_cast(Block) - 1; @@ -599,7 +593,6 @@ FreeMemoryList = Mem0; GOTBase = NULL; - DlsymTable = NULL; } void DefaultJITMemoryManager::AllocateGOT() { @@ -608,10 +601,6 @@ HasGOT = true; } -void DefaultJITMemoryManager::SetDlsymTable(void *ptr) { - DlsymTable = ptr; -} - DefaultJITMemoryManager::~DefaultJITMemoryManager() { for (unsigned i = 0, e = CodeSlabs.size(); i != e; ++i) sys::Memory::ReleaseRWX(CodeSlabs[i]); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=86606&r1=86605&r2=86606&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Nov 9 16:34:19 2009 @@ -68,8 +68,6 @@ virtual void setPoisonMemory(bool poison) { Base->setPoisonMemory(poison); } virtual void AllocateGOT() { Base->AllocateGOT(); } virtual uint8_t *getGOTBase() const { return Base->getGOTBase(); } - virtual void SetDlsymTable(void *ptr) { Base->SetDlsymTable(ptr); } - virtual void *getDlsymTable() const { return Base->getDlsymTable(); } struct StartFunctionBodyCall { StartFunctionBodyCall(uint8_t *Result, const Function *F, uintptr_t ActualSize, uintptr_t ActualSizeResult) @@ -303,7 +301,6 @@ ConstantInt::get(TypeBuilder::get(Context), 7)); Builder.CreateRet(result); - TheJIT->EnableDlsymStubs(false); TheJIT->DisableLazyCompilation(true); int (*TestFunctionPtr)() = reinterpret_cast( (intptr_t)TheJIT->getPointerToFunction(TestFunction)); From anton at korobeynikov.info Mon Nov 9 16:37:48 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 10 Nov 2009 01:37:48 +0300 Subject: [llvm-commits] [llvm] r86604 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp In-Reply-To: <200911092232.nA9MWeAk002613@zion.cs.uiuc.edu> References: <200911092232.nA9MWeAk002613@zion.cs.uiuc.edu> Message-ID: <1257806268.7975.104.camel@aslstation> Hello, Jim > static cl::opt > -ARMDynamicStackAlign("arm-dynamic-stack-alignment", cl::Hidden, cl::init(false), > +ARMDynamicStackAlign("arm-dynamic-stack-alignment", cl::Hidden, cl::init(true), > cl::desc("Dynamically re-align the stack as needed")); We already have generic 'RealignStack' flag. Please use it. -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From sabre at nondot.org Mon Nov 9 16:57:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 22:57:59 -0000 Subject: [llvm-commits] [llvm] r86613 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/CMakeLists.txt lib/Analysis/InstructionSimplify.cpp Message-ID: <200911092257.nA9MvxAt004112@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 16:57:59 2009 New Revision: 86613 URL: http://llvm.org/viewvc/llvm-project?rev=86613&view=rev Log: stub out a new libanalysis "instruction simplify" interface that takes decimated instructions and applies identities to them. This is pretty minimal at this point, but I plan to pull some instcombine logic out into these and similar routines. Added: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp Modified: llvm/trunk/lib/Analysis/CMakeLists.txt Added: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86613&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (added) +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Mon Nov 9 16:57:59 2009 @@ -0,0 +1,37 @@ +//===-- InstructionSimplify.h - Fold instructions into simpler forms ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares routines for folding instructions into simpler forms that +// do not require creating new instructions. For example, this does constant +// folding, and can handle identities like (X&0)->0. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H +#define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H + +namespace llvm { + class Value; + class TargetData; + + /// SimplifyCompare - Given operands for a CmpInst, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD = 0); + + + /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, + const TargetData *TD = 0); + +} // end namespace llvm + +#endif + Modified: llvm/trunk/lib/Analysis/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=86613&r1=86612&r2=86613&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) +++ llvm/trunk/lib/Analysis/CMakeLists.txt Mon Nov 9 16:57:59 2009 @@ -15,6 +15,7 @@ IVUsers.cpp InlineCost.cpp InstCount.cpp + InstructionSimplify.cpp Interval.cpp IntervalPartition.cpp LibCallAliasAnalysis.cpp Added: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86613&view=auto ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (added) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 16:57:59 2009 @@ -0,0 +1,57 @@ +//===- InstructionSimplify.cpp - Fold instruction operands ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements routines for folding instructions into simpler forms +// that do not require creating new instructions. For example, this does +// constant folding, and can handle identities like (X&0)->0. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/InstructionSimplify.h" +#include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Instructions.h" +using namespace llvm; + + +/// SimplifyBinOp - Given operands for a BinaryOperator, see if we can +/// fold the result. If not, this returns null. +Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, + const TargetData *TD) { + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) { + Constant *COps[] = {CLHS, CRHS}; + return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, 2, TD); + } + return 0; +} + + +/// SimplifyCompare - Given operands for a CmpInst, see if we can +/// fold the result. +Value *llvm::SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD) { + CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; + + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) { + Constant *COps[] = {CLHS, CRHS}; + return ConstantFoldCompareInstOperands(Pred, COps, 2, TD); + } + + // If this is an integer compare and the LHS and RHS are the same, fold it. + if (LHS == RHS) + if (isa(LHS->getType()) || isa(LHS->getType())) { + if (ICmpInst::isTrueWhenEqual(Pred)) + return ConstantInt::getTrue(LHS->getContext()); + else + return ConstantInt::getFalse(LHS->getContext()); + } + return 0; +} + From grosbach at apple.com Mon Nov 9 16:59:01 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 Nov 2009 22:59:01 -0000 Subject: [llvm-commits] [llvm] r86614 - /llvm/trunk/test/CodeGen/Thumb2/large-stack.ll Message-ID: <200911092259.nA9Mx1RR004163@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 9 16:59:01 2009 New Revision: 86614 URL: http://llvm.org/viewvc/llvm-project?rev=86614&view=rev Log: Update test Modified: llvm/trunk/test/CodeGen/Thumb2/large-stack.ll Modified: llvm/trunk/test/CodeGen/Thumb2/large-stack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/large-stack.ll?rev=86614&r1=86613&r2=86614&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/large-stack.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/large-stack.ll Mon Nov 9 16:59:01 2009 @@ -18,7 +18,7 @@ define i32 @test3() { ; CHECK: test3: ; CHECK: sub.w sp, sp, #805306368 -; CHECK: sub sp, #4 * 4 +; CHECK: sub sp, #6 * 4 %retval = alloca i32, align 4 %tmp = alloca i32, align 4 %a = alloca [805306369 x i8], align 16 From sabre at nondot.org Mon Nov 9 17:00:14 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 23:00:14 -0000 Subject: [llvm-commits] [llvm] r86616 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911092300.nA9N0Euu004227@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 17:00:14 2009 New Revision: 86616 URL: http://llvm.org/viewvc/llvm-project?rev=86616&view=rev Log: use instructionsimplify instead of a weak clone of ad-hoc folding stuff. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86616&r1=86615&r2=86616&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 17:00:14 2009 @@ -17,6 +17,7 @@ #include "llvm/LLVMContext.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/SSAUpdater.h" @@ -203,7 +204,6 @@ // Remove the entries for Pred from the PHI nodes in BB, but do not simplify // them down. This will leave us with single entry phi nodes and other phis // that can be removed. - //BB->removePredecessor(Pred, true); BB->removePredecessor(Pred, true); WeakVH PhiIt = &BB->front(); @@ -266,26 +266,6 @@ LoopHeaders.insert(const_cast(Edges[i].second)); } -/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right -/// hand sides of the compare instruction, try to determine the result. If the -/// result can not be determined, a null pointer is returned. -static Constant *GetResultOfComparison(CmpInst::Predicate pred, - Value *LHS, Value *RHS) { - if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) - return ConstantExpr::getCompare(pred, CLHS, CRHS); - - if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) { - if (ICmpInst::isTrueWhenEqual(pred)) - return ConstantInt::getTrue(LHS->getContext()); - else - return ConstantInt::getFalse(LHS->getContext()); - } - return 0; -} - - /// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see /// if we can infer that the value is a known ConstantInt in any of our /// predecessors. If so, return the known list of value and pred BB in the @@ -374,7 +354,7 @@ Value *LHS = PN->getIncomingValue(i); Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); - Constant *Res = GetResultOfComparison(Cmp->getPredicate(), LHS, RHS); + Value *Res = SimplifyCompare(Cmp->getPredicate(), LHS, RHS); if (Res == 0) continue; if (isa(Res)) From daniel at zuster.org Mon Nov 9 17:05:44 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 09 Nov 2009 23:05:44 -0000 Subject: [llvm-commits] [llvm] r86618 - /llvm/trunk/include/llvm/ADT/StringSwitch.h Message-ID: <200911092305.nA9N5jlM004456@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 17:05:44 2009 New Revision: 86618 URL: http://llvm.org/viewvc/llvm-project?rev=86618&view=rev Log: Add StringSwitch::Cases overloads, for matching multiple strings to a single value. Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringSwitch.h?rev=86618&r1=86617&r2=86618&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringSwitch.h (original) +++ llvm/trunk/include/llvm/ADT/StringSwitch.h Mon Nov 9 17:05:44 2009 @@ -65,6 +65,25 @@ return *this; } + template + StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], + const T& Value) { + return Case(S0, Value).Case(S1, Value); + } + + template + StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], + const char (&S2)[N2], const T& Value) { + return Case(S0, Value).Case(S1, Value).Case(S2, Value); + } + + template + StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], + const char (&S2)[N2], const char (&S3)[N3], + const T& Value) { + return Case(S0, Value).Case(S1, Value).Case(S2, Value).Case(S3, Value); + } + T Default(const T& Value) { if (ResultKnown) return Result; From sabre at nondot.org Mon Nov 9 17:06:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 23:06:58 -0000 Subject: [llvm-commits] [llvm] r86619 - in /llvm/trunk: include/llvm/Analysis/ConstantFolding.h lib/Analysis/ConstantFolding.cpp lib/Analysis/InstructionSimplify.cpp lib/Analysis/ScalarEvolution.cpp lib/Transforms/Utils/CloneFunction.cpp Message-ID: <200911092306.nA9N6wHx004509@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 17:06:58 2009 New Revision: 86619 URL: http://llvm.org/viewvc/llvm-project?rev=86619&view=rev Log: fix ConstantFoldCompareInstOperands to take the LHS/RHS as individual operands instead of taking a temporary array Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=86619&r1=86618&r2=86619&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Mon Nov 9 17:06:58 2009 @@ -55,7 +55,7 @@ /// returns a constant expression of the specified operands. /// Constant *ConstantFoldCompareInstOperands(unsigned Predicate, - Constant *const *Ops, unsigned NumOps, + Constant *LHS, Constant *RHS, const TargetData *TD = 0); /// ConstantFoldLoadFromConstPtr - Return the value that a load from C would Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=86619&r1=86618&r2=86619&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Nov 9 17:06:58 2009 @@ -655,8 +655,8 @@ return 0; // All operands not constant! if (const CmpInst *CI = dyn_cast(I)) - return ConstantFoldCompareInstOperands(CI->getPredicate(), - Ops.data(), Ops.size(), TD); + return ConstantFoldCompareInstOperands(CI->getPredicate(), Ops[0], Ops[1], + TD); if (const LoadInst *LI = dyn_cast(I)) return ConstantFoldLoadInst(LI, TD); @@ -675,8 +675,8 @@ Ops.push_back(cast(*i)); if (CE->isCompare()) - return ConstantFoldCompareInstOperands(CE->getPredicate(), - Ops.data(), Ops.size(), TD); + return ConstantFoldCompareInstOperands(CE->getPredicate(), Ops[0], Ops[1], + TD); return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), Ops.data(), Ops.size(), TD); } @@ -806,8 +806,7 @@ /// returns a constant expression of the specified operands. /// Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, - Constant *const *Ops, - unsigned NumOps, + Constant *Ops0, Constant *Ops1, const TargetData *TD) { // fold: icmp (inttoptr x), null -> icmp x, 0 // fold: icmp (ptrtoint x), 0 -> icmp x, null @@ -816,16 +815,16 @@ // // ConstantExpr::getCompare cannot do this, because it doesn't have TD // around to know if bit truncation is happening. - if (ConstantExpr *CE0 = dyn_cast(Ops[0])) { - if (TD && Ops[1]->isNullValue()) { + if (ConstantExpr *CE0 = dyn_cast(Ops0)) { + if (TD && Ops1->isNullValue()) { const Type *IntPtrTy = TD->getIntPtrType(CE0->getContext()); if (CE0->getOpcode() == Instruction::IntToPtr) { // Convert the integer value to the right size to ensure we get the // proper extension or truncation. Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0), IntPtrTy, false); - Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + Constant *Null = Constant::getNullValue(C->getType()); + return ConstantFoldCompareInstOperands(Predicate, C, Null, TD); } // Only do this transformation if the int is intptrty in size, otherwise @@ -833,13 +832,12 @@ if (CE0->getOpcode() == Instruction::PtrToInt && CE0->getType() == IntPtrTy) { Constant *C = CE0->getOperand(0); - Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; - // FIXME! - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + Constant *Null = Constant::getNullValue(C->getType()); + return ConstantFoldCompareInstOperands(Predicate, C, Null, TD); } } - if (ConstantExpr *CE1 = dyn_cast(Ops[1])) { + if (ConstantExpr *CE1 = dyn_cast(Ops1)) { if (TD && CE0->getOpcode() == CE1->getOpcode()) { const Type *IntPtrTy = TD->getIntPtrType(CE0->getContext()); @@ -850,24 +848,21 @@ IntPtrTy, false); Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0), IntPtrTy, false); - Constant *NewOps[] = { C0, C1 }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); + return ConstantFoldCompareInstOperands(Predicate, C0, C1, TD); } // Only do this transformation if the int is intptrty in size, otherwise // there is a truncation or extension that we aren't modeling. if ((CE0->getOpcode() == Instruction::PtrToInt && CE0->getType() == IntPtrTy && - CE0->getOperand(0)->getType() == CE1->getOperand(0)->getType())) { - Constant *NewOps[] = { - CE0->getOperand(0), CE1->getOperand(0) - }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); - } + CE0->getOperand(0)->getType() == CE1->getOperand(0)->getType())) + return ConstantFoldCompareInstOperands(Predicate, CE0->getOperand(0), + CE1->getOperand(0), TD); } } } - return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]); + + return ConstantExpr::getCompare(Predicate, Ops0, Ops1); } Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86619&r1=86618&r2=86619&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 17:06:58 2009 @@ -39,10 +39,8 @@ CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) { - Constant *COps[] = {CLHS, CRHS}; - return ConstantFoldCompareInstOperands(Pred, COps, 2, TD); - } + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); // If this is an integer compare and the LHS and RHS are the same, fold it. if (LHS == RHS) Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=86619&r1=86618&r2=86619&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Nov 9 17:06:58 2009 @@ -3826,11 +3826,10 @@ } if (const CmpInst *CI = dyn_cast(I)) - return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size()); - else - return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size()); + return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0], + Operands[1]); + return ConstantFoldInstOperands(I->getOpcode(), I->getType(), + &Operands[0], Operands.size()); } /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is @@ -4037,7 +4036,7 @@ Constant *C; if (const CmpInst *CI = dyn_cast(I)) C = ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size()); + Operands[0], Operands[1]); else C = ConstantFoldInstOperands(I->getOpcode(), I->getType(), &Operands[0], Operands.size()); Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=86619&r1=86618&r2=86619&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Nov 9 17:06:58 2009 @@ -331,8 +331,8 @@ return 0; // All operands not constant! if (const CmpInst *CI = dyn_cast(I)) - return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Ops[0], Ops.size(), TD); + return ConstantFoldCompareInstOperands(CI->getPredicate(), Ops[0], Ops[1], + TD); if (const LoadInst *LI = dyn_cast(I)) if (ConstantExpr *CE = dyn_cast(Ops[0])) From mrs at apple.com Mon Nov 9 17:10:49 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 09 Nov 2009 23:10:49 -0000 Subject: [llvm-commits] [llvm] r86620 - /llvm/trunk/test/CodeGen/X86/object-size.ll Message-ID: <200911092310.nA9NAn5d004635@zion.cs.uiuc.edu> Author: mrs Date: Mon Nov 9 17:10:49 2009 New Revision: 86620 URL: http://llvm.org/viewvc/llvm-project?rev=86620&view=rev Log: Add testcase for recent checkin. Added: llvm/trunk/test/CodeGen/X86/object-size.ll Added: llvm/trunk/test/CodeGen/X86/object-size.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/object-size.ll?rev=86620&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/object-size.ll (added) +++ llvm/trunk/test/CodeGen/X86/object-size.ll Mon Nov 9 17:10:49 2009 @@ -0,0 +1,55 @@ +; RUN: llc -O0 < %s -march=x86-64 | FileCheck %s -check-prefix=X64 + +; ModuleID = 'ts.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0" + + at p = common global i8* null, align 8 ; [#uses=4] + at .str = private constant [3 x i8] c"Hi\00" ; <[3 x i8]*> [#uses=1] + +define void @bar() nounwind ssp { +entry: + %tmp = load i8** @p ; [#uses=1] + %0 = call i64 @llvm.objectsize.i64(i8* %tmp, i32 0) ; [#uses=1] + %cmp = icmp ne i64 %0, -1 ; [#uses=1] +; X64: movq $-1, %rax +; X64: cmpq $-1, %rax + br i1 %cmp, label %cond.true, label %cond.false + +cond.true: ; preds = %entry + %tmp1 = load i8** @p ; [#uses=1] + %tmp2 = load i8** @p ; [#uses=1] + %1 = call i64 @llvm.objectsize.i64(i8* %tmp2, i32 1) ; [#uses=1] + %call = call i8* @__strcpy_chk(i8* %tmp1, i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i64 %1) ssp ; [#uses=1] + br label %cond.end + +cond.false: ; preds = %entry + %tmp3 = load i8** @p ; [#uses=1] + %call4 = call i8* @__inline_strcpy_chk(i8* %tmp3, i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0)) ssp ; [#uses=1] + br label %cond.end + +cond.end: ; preds = %cond.false, %cond.true + %cond = phi i8* [ %call, %cond.true ], [ %call4, %cond.false ] ; [#uses=0] + ret void +} + +declare i64 @llvm.objectsize.i64(i8*, i32) nounwind readonly + +declare i8* @__strcpy_chk(i8*, i8*, i64) ssp + +define internal i8* @__inline_strcpy_chk(i8* %__dest, i8* %__src) nounwind ssp { +entry: + %retval = alloca i8* ; [#uses=2] + %__dest.addr = alloca i8* ; [#uses=3] + %__src.addr = alloca i8* ; [#uses=2] + store i8* %__dest, i8** %__dest.addr + store i8* %__src, i8** %__src.addr + %tmp = load i8** %__dest.addr ; [#uses=1] + %tmp1 = load i8** %__src.addr ; [#uses=1] + %tmp2 = load i8** %__dest.addr ; [#uses=1] + %0 = call i64 @llvm.objectsize.i64(i8* %tmp2, i32 1) ; [#uses=1] + %call = call i8* @__strcpy_chk(i8* %tmp, i8* %tmp1, i64 %0) ssp ; [#uses=1] + store i8* %call, i8** %retval + %1 = load i8** %retval ; [#uses=1] + ret i8* %1 +} From grosbach at apple.com Mon Nov 9 17:11:45 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 Nov 2009 23:11:45 -0000 Subject: [llvm-commits] [llvm] r86621 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911092311.nA9NBj4a004671@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 9 17:11:45 2009 New Revision: 86621 URL: http://llvm.org/viewvc/llvm-project?rev=86621&view=rev Log: Now that the default is 'enabled,' a separate command line option for ARM is not necessary. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86621&r1=86620&r2=86621&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Nov 9 17:11:45 2009 @@ -44,10 +44,6 @@ ReuseFrameIndexVals("arm-reuse-frame-index-vals", cl::Hidden, cl::init(true), cl::desc("Reuse repeated frame index values")); -static cl::opt -ARMDynamicStackAlign("arm-dynamic-stack-alignment", cl::Hidden, cl::init(true), - cl::desc("Dynamically re-align the stack as needed")); - unsigned ARMBaseRegisterInfo::getRegisterNumbering(unsigned RegEnum, bool *isSPVFP) { if (isSPVFP) @@ -504,9 +500,6 @@ bool ARMBaseRegisterInfo:: needsStackRealignment(const MachineFunction &MF) const { - if (!ARMDynamicStackAlign) - return false; - const MachineFrameInfo *MFI = MF.getFrameInfo(); const ARMFunctionInfo *AFI = MF.getInfo(); unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); @@ -596,7 +589,7 @@ // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). - if (ARMDynamicStackAlign) { + if (RealignStack) { unsigned MaxAlign = std::max(MFI->getMaxAlignment(), calculateMaxStackAlignment(MFI)); MFI->setMaxAlignment(MaxAlign); From mrs at apple.com Mon Nov 9 17:12:38 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 9 Nov 2009 15:12:38 -0800 Subject: [llvm-commits] [llvm] r86600 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <6D81D7E0-1A25-4A71-99DE-685A7096A4A5@apple.com> References: <200911092228.nA9MSLFw002262@zion.cs.uiuc.edu> <6D81D7E0-1A25-4A71-99DE-685A7096A4A5@apple.com> Message-ID: On Nov 9, 2009, at 2:29 PM, Eric Christopher wrote: > On Nov 9, 2009, at 2:28 PM, Mike Stump wrote: >> Fix for 64-bit builds. > > Thanks. Guess that did work :) > > Please throw a testcase in somewhere to make sure I don't break it. Sure, checked in r86620. From nlewycky at google.com Mon Nov 9 17:17:27 2009 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 9 Nov 2009 15:17:27 -0800 Subject: [llvm-commits] [llvm] r86613 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/CMakeLists.txt lib/Analysis/InstructionSimplify.cpp In-Reply-To: <200911092257.nA9MvxAt004112@zion.cs.uiuc.edu> References: <200911092257.nA9MvxAt004112@zion.cs.uiuc.edu> Message-ID: 2009/11/9 Chris Lattner > Author: lattner > Date: Mon Nov 9 16:57:59 2009 > New Revision: 86613 > > URL: http://llvm.org/viewvc/llvm-project?rev=86613&view=rev > Log: > stub out a new libanalysis "instruction simplify" interface that > takes decimated instructions and applies identities to them. This > is pretty minimal at this point, but I plan to pull some instcombine > logic out into these and similar routines. > > Added: > llvm/trunk/include/llvm/Analysis/InstructionSimplify.h > llvm/trunk/lib/Analysis/InstructionSimplify.cpp > Modified: > llvm/trunk/lib/Analysis/CMakeLists.txt > > Added: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86613&view=auto > > > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (added) > +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Mon Nov 9 > 16:57:59 2009 > @@ -0,0 +1,37 @@ > +//===-- InstructionSimplify.h - Fold instructions into simpler forms > ------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file declares routines for folding instructions into simpler forms > that > +// do not require creating new instructions. For example, this does > constant > +// folding, and can handle identities like (X&0)->0. > +// > > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H > +#define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H > + > +namespace llvm { > + class Value; > + class TargetData; > + > + /// SimplifyCompare - Given operands for a CmpInst, see if we can > + /// fold the result. If not, this returns null. > + Value *SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, > + const TargetData *TD = 0); > + > + > + /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can > + /// fold the result. If not, this returns null. > + Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, > + const TargetData *TD = 0); > + > +} // end namespace llvm > + > +#endif > + > > Modified: llvm/trunk/lib/Analysis/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=86613&r1=86612&r2=86613&view=diff > > > ============================================================================== > --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) > +++ llvm/trunk/lib/Analysis/CMakeLists.txt Mon Nov 9 16:57:59 2009 > @@ -15,6 +15,7 @@ > IVUsers.cpp > InlineCost.cpp > InstCount.cpp > + InstructionSimplify.cpp > Interval.cpp > IntervalPartition.cpp > LibCallAliasAnalysis.cpp > > Added: llvm/trunk/lib/Analysis/InstructionSimplify.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86613&view=auto > > > ============================================================================== > --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (added) > +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 16:57:59 > 2009 > @@ -0,0 +1,57 @@ > +//===- InstructionSimplify.cpp - Fold instruction operands > ----------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file implements routines for folding instructions into simpler > forms > +// that do not require creating new instructions. For example, this does > +// constant folding, and can handle identities like (X&0)->0. > +// > > +//===----------------------------------------------------------------------===// > + > +#include "llvm/Analysis/InstructionSimplify.h" > +#include "llvm/Analysis/ConstantFolding.h" > +#include "llvm/Instructions.h" > +using namespace llvm; > + > + > +/// SimplifyBinOp - Given operands for a BinaryOperator, see if we can > +/// fold the result. If not, this returns null. > +Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, > + const TargetData *TD) { > + if (Constant *CLHS = dyn_cast(LHS)) > + if (Constant *CRHS = dyn_cast(RHS)) { > + Constant *COps[] = {CLHS, CRHS}; > + return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, 2, > TD); > + } > + return 0; > +} > + > + > +/// SimplifyCompare - Given operands for a CmpInst, see if we can > +/// fold the result. > +Value *llvm::SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, > + const TargetData *TD) { > + CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; > + > + if (Constant *CLHS = dyn_cast(LHS)) > + if (Constant *CRHS = dyn_cast(RHS)) { > + Constant *COps[] = {CLHS, CRHS}; > + return ConstantFoldCompareInstOperands(Pred, COps, 2, TD); > + } > + > + // If this is an integer compare and the LHS and RHS are the same, fold > it. > + if (LHS == RHS) > + if (isa(LHS->getType()) || > isa(LHS->getType())) { > + if (ICmpInst::isTrueWhenEqual(Pred)) > + return ConstantInt::getTrue(LHS->getContext()); > + else > + return ConstantInt::getFalse(LHS->getContext()); > + } > There's an CmpInst::isTrueWhenEqual and CmpInst::isFalseWhenEqual, both of which work on icmp and fcmp. Please use that instead, adding support for floats in the process! Nick > + return 0; > +} > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/48444335/attachment.html From sabre at nondot.org Mon Nov 9 17:28:39 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 23:28:39 -0000 Subject: [llvm-commits] [llvm] r86624 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h include/llvm/InstrTypes.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/Scalar/InstructionCombining.cpp lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911092328.nA9NSeZs005269@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 17:28:39 2009 New Revision: 86624 URL: http://llvm.org/viewvc/llvm-project?rev=86624&view=rev Log: rename SimplifyCompare -> SimplifyCmpInst and split it into Simplify[IF]Cmp pieces. Add some predicates to CmpInst to determine whether a predicate is fp or int. Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86624&r1=86623&r2=86624&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original) +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Mon Nov 9 17:28:39 2009 @@ -20,11 +20,24 @@ class Value; class TargetData; - /// SimplifyCompare - Given operands for a CmpInst, see if we can + /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can /// fold the result. If not, this returns null. - Value *SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, + Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const TargetData *TD = 0); + /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD = 0); + + + //=== Helper functions for higher up the class hierarchy. + + + /// SimplifyCmpInst - Given operands for a CmpInst, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD = 0); /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can /// fold the result. If not, this returns null. Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=86624&r1=86623&r2=86624&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Mon Nov 9 17:28:39 2009 @@ -658,7 +658,7 @@ /// @brief Create a CmpInst static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name, BasicBlock *InsertAtEnd); - + /// @brief Get the opcode casted to the right type OtherOps getOpcode() const { return static_cast(Instruction::getOpcode()); @@ -670,6 +670,18 @@ /// @brief Set the predicate for this instruction to the specified value. void setPredicate(Predicate P) { SubclassData = P; } + static bool isFPPredicate(Predicate P) { + return P >= FIRST_FCMP_PREDICATE && P <= LAST_FCMP_PREDICATE; + } + + static bool isIntPredicate(Predicate P) { + return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE; + } + + bool isFPPredicate() const { return isFPPredicate(getPredicate()); } + bool isIntPredicate() const { return isIntPredicate(getPredicate()); } + + /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. /// @returns the inverse predicate for the instruction's current predicate. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86624&r1=86623&r2=86624&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 17:28:39 2009 @@ -32,11 +32,12 @@ } -/// SimplifyCompare - Given operands for a CmpInst, see if we can -/// fold the result. -Value *llvm::SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, - const TargetData *TD) { +/// SimplifyICmpInst - Given operands for an ICmpInst, see if we can +/// fold the result. If not, this returns null. +Value *llvm::SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD) { CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; + assert(CmpInst::isIntPredicate(Pred) && "Not an integer compare!"); if (Constant *CLHS = dyn_cast(LHS)) if (Constant *CRHS = dyn_cast(RHS)) @@ -44,12 +45,36 @@ // If this is an integer compare and the LHS and RHS are the same, fold it. if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) { - if (ICmpInst::isTrueWhenEqual(Pred)) - return ConstantInt::getTrue(LHS->getContext()); - else - return ConstantInt::getFalse(LHS->getContext()); - } + if (ICmpInst::isTrueWhenEqual(Pred)) + return ConstantInt::getTrue(LHS->getContext()); + else + return ConstantInt::getFalse(LHS->getContext()); + + return 0; +} + +/// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can +/// fold the result. If not, this returns null. +Value *llvm::SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD) { + CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; + assert(CmpInst::isFPPredicate(Pred) && "Not an FP compare!"); + + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); + return 0; } + + +/// SimplifyCmpInst - Given operands for a CmpInst, see if we can +/// fold the result. +Value *llvm::SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD) { + if (CmpInst::isIntPredicate((CmpInst::Predicate)Predicate)) + return SimplifyICmpInst(Predicate, LHS, RHS, TD); + return SimplifyFCmpInst(Predicate, LHS, RHS, TD); +} + Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86624&r1=86623&r2=86624&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Nov 9 17:28:39 2009 @@ -42,6 +42,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Operator.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86624&r1=86623&r2=86624&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 17:28:39 2009 @@ -354,7 +354,7 @@ Value *LHS = PN->getIncomingValue(i); Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); - Value *Res = SimplifyCompare(Cmp->getPredicate(), LHS, RHS); + Value *Res = SimplifyCmpInst(Cmp->getPredicate(), LHS, RHS); if (Res == 0) continue; if (isa(Res)) From sabre at nondot.org Mon Nov 9 17:31:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 23:31:49 -0000 Subject: [llvm-commits] [llvm] r86625 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911092331.nA9NVn5c005428@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 17:31:49 2009 New Revision: 86625 URL: http://llvm.org/viewvc/llvm-project?rev=86625&view=rev Log: inline a simple function. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86625&r1=86624&r2=86625&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Nov 9 17:31:49 2009 @@ -383,10 +383,6 @@ /// commutative operators. bool SimplifyCommutative(BinaryOperator &I); - /// SimplifyCompare - This reorders the operands of a CmpInst to get them in - /// most-complex to least-complex order. - bool SimplifyCompare(CmpInst &I); - /// SimplifyDemandedUseBits - Attempts to replace V with a simpler value /// based on the demanded bits. Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, @@ -587,17 +583,6 @@ return Changed; } -/// SimplifyCompare - For a CmpInst this function just orders the operands -/// so that theyare listed from right (least complex) to left (most complex). -/// This puts constants before unary operators before binary operators. -bool InstCombiner::SimplifyCompare(CmpInst &I) { - if (getComplexity(I.getOperand(0)) >= getComplexity(I.getOperand(1))) - return false; - I.swapOperands(); - // Compare instructions are not associative so there's nothing else we can do. - return true; -} - // dyn_castNegVal - Given a 'sub' instruction, return the RHS of the instruction // if the LHS is a constant zero (which is the 'negate' form). // @@ -5945,7 +5930,16 @@ } Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { - bool Changed = SimplifyCompare(I); + bool Changed = false; + + /// Orders the operands of the compare so that they are listed from most + /// complex to least complex. This puts constants before unary operators, + /// before binary operators. + if (getComplexity(I.getOperand(0)) < getComplexity(I.getOperand(1))) { + I.swapOperands(); + Changed = true; + } + Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); // Fold trivial predicates. @@ -6050,7 +6044,16 @@ } Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { - bool Changed = SimplifyCompare(I); + bool Changed = false; + + /// Orders the operands of the compare so that they are listed from most + /// complex to least complex. This puts constants before unary operators, + /// before binary operators. + if (getComplexity(I.getOperand(0)) < getComplexity(I.getOperand(1))) { + I.swapOperands(); + Changed = true; + } + Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); const Type *Ty = Op0->getType(); From gohman at apple.com Mon Nov 9 17:34:17 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 Nov 2009 23:34:17 -0000 Subject: [llvm-commits] [llvm] r86626 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200911092334.nA9NYHYj005520@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 17:34:17 2009 New Revision: 86626 URL: http://llvm.org/viewvc/llvm-project?rev=86626&view=rev Log: Pass the (optional) TargetData object to ConstantFoldInstOperands and ConstantFoldCompareInstOperands. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=86626&r1=86625&r2=86626&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Nov 9 17:34:17 2009 @@ -3811,7 +3811,8 @@ /// getConstantEvolvingPHI predicate, evaluate its value assuming the PHI node /// in the loop has the value PHIVal. If we can't fold this expression for some /// reason, return null. -static Constant *EvaluateExpression(Value *V, Constant *PHIVal) { +static Constant *EvaluateExpression(Value *V, Constant *PHIVal, + const TargetData *TD) { if (isa(V)) return PHIVal; if (Constant *C = dyn_cast(V)) return C; if (GlobalValue *GV = dyn_cast(V)) return GV; @@ -3821,15 +3822,15 @@ Operands.resize(I->getNumOperands()); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - Operands[i] = EvaluateExpression(I->getOperand(i), PHIVal); + Operands[i] = EvaluateExpression(I->getOperand(i), PHIVal, TD); if (Operands[i] == 0) return 0; } if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0], - Operands[1]); + Operands[1], TD); return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), TD); } /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is @@ -3875,7 +3876,7 @@ return RetVal = PHIVal; // Got exit value! // Compute the value of the PHI node for the next iteration. - Constant *NextPHI = EvaluateExpression(BEValue, PHIVal); + Constant *NextPHI = EvaluateExpression(BEValue, PHIVal, TD); if (NextPHI == PHIVal) return RetVal = NextPHI; // Stopped evolving! if (NextPHI == 0) @@ -3916,7 +3917,7 @@ for (Constant *PHIVal = StartCST; IterationNum != MaxIterations; ++IterationNum) { ConstantInt *CondVal = - dyn_cast_or_null(EvaluateExpression(Cond, PHIVal)); + dyn_cast_or_null(EvaluateExpression(Cond, PHIVal, TD)); // Couldn't symbolically evaluate. if (!CondVal) return getCouldNotCompute(); @@ -3927,7 +3928,7 @@ } // Compute the value of the PHI node for the next iteration. - Constant *NextPHI = EvaluateExpression(BEValue, PHIVal); + Constant *NextPHI = EvaluateExpression(BEValue, PHIVal, TD); if (NextPHI == 0 || NextPHI == PHIVal) return getCouldNotCompute();// Couldn't evaluate or not making progress... PHIVal = NextPHI; @@ -4036,10 +4037,10 @@ Constant *C; if (const CmpInst *CI = dyn_cast(I)) C = ConstantFoldCompareInstOperands(CI->getPredicate(), - Operands[0], Operands[1]); + Operands[0], Operands[1], TD); else C = ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size()); + &Operands[0], Operands.size(), TD); return getSCEV(C); } } From mrs at apple.com Mon Nov 9 17:48:01 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 9 Nov 2009 15:48:01 -0800 Subject: [llvm-commits] [llvm] r86547 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake In-Reply-To: <200911091526.nA9FQhRr016776@zion.cs.uiuc.edu> References: <200911091526.nA9FQhRr016776@zion.cs.uiuc.edu> Message-ID: <05076F8D-8E99-4BCD-BDA0-AB1F2FD5DA05@apple.com> On Nov 9, 2009, at 7:26 AM, Oscar Fuentes wrote: > Author: ofv > Date: Mon Nov 9 09:26:40 2009 > New Revision: 86547 > > URL: http://llvm.org/viewvc/llvm-project?rev=86547&view=rev > Log: > CMake: Detect gv, circo, twopi, neato, fdo, dot and dotty. > + unset(LLVM_PATH_${NAME} CACHE) I get: -- Performing Test HAVE_U_INT64_T - Success CMake Error at cmake/config-ix.cmake:139 (unset): Unknown CMake command "unset". Call Stack (most recent call first): cmake/config-ix.cmake:143 (llvm_find_program) CMakeLists.txt:161 (include) -- Configuring incomplete, errors occurred! ? I'm using cmake version 2.6-patch 2. From sabre at nondot.org Mon Nov 9 17:55:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 09 Nov 2009 23:55:12 -0000 Subject: [llvm-commits] [llvm] r86627 - in /llvm/trunk/lib: Analysis/InstructionSimplify.cpp Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911092355.nA9NtCrp006300@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 17:55:12 2009 New Revision: 86627 URL: http://llvm.org/viewvc/llvm-project?rev=86627&view=rev Log: pull a bunch of logic out of instcombine into instsimplify for compare simplification, this handles the foldable fcmp x,x cases among many others. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86627&r1=86626&r2=86627&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 17:55:12 2009 @@ -31,6 +31,10 @@ return 0; } +static const Type *GetCompareTy(Value *Op) { + return CmpInst::makeCmpResultType(Op->getType()); +} + /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can /// fold the result. If not, this returns null. @@ -43,13 +47,59 @@ if (Constant *CRHS = dyn_cast(RHS)) return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); - // If this is an integer compare and the LHS and RHS are the same, fold it. + // ITy - This is the return type of the compare we're considering. + const Type *ITy = GetCompareTy(LHS); + + // icmp X, X -> true/false if (LHS == RHS) - if (ICmpInst::isTrueWhenEqual(Pred)) - return ConstantInt::getTrue(LHS->getContext()); - else - return ConstantInt::getFalse(LHS->getContext()); + return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred)); + // If we have a constant, make sure it is on the RHS. + if (isa(LHS)) { + std::swap(LHS, RHS); + Pred = CmpInst::getSwappedPredicate(Pred); + } + + if (isa(RHS)) // X icmp undef -> undef + return UndefValue::get(ITy); + + // icmp , - Global/Stack value + // addresses never equal each other! We already know that Op0 != Op1. + if ((isa(LHS) || isa(LHS) || + isa(LHS)) && + (isa(RHS) || isa(RHS) || + isa(RHS))) + return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred)); + + // See if we are doing a comparison with a constant. + if (ConstantInt *CI = dyn_cast(RHS)) { + // If we have an icmp le or icmp ge instruction, turn it into the + // appropriate icmp lt or icmp gt instruction. This allows us to rely on + // them being folded in the code below. + switch (Pred) { + default: break; + case ICmpInst::ICMP_ULE: + if (CI->isMaxValue(false)) // A <=u MAX -> TRUE + return ConstantInt::getTrue(CI->getContext()); + break; + case ICmpInst::ICMP_SLE: + if (CI->isMaxValue(true)) // A <=s MAX -> TRUE + return ConstantInt::getTrue(CI->getContext()); + break; + case ICmpInst::ICMP_UGE: + if (CI->isMinValue(false)) // A >=u MIN -> TRUE + return ConstantInt::getTrue(CI->getContext()); + break; + case ICmpInst::ICMP_SGE: + if (CI->isMinValue(true)) // A >=s MIN -> TRUE + return ConstantInt::getTrue(CI->getContext()); + break; + } + + + } + + return 0; } @@ -64,6 +114,44 @@ if (Constant *CRHS = dyn_cast(RHS)) return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); + // Fold trivial predicates. + if (Pred == FCmpInst::FCMP_FALSE) + return ConstantInt::get(GetCompareTy(LHS), 0); + if (Pred == FCmpInst::FCMP_TRUE) + return ConstantInt::get(GetCompareTy(LHS), 1); + + // If we have a constant, make sure it is on the RHS. + if (isa(LHS)) { + std::swap(LHS, RHS); + Pred = CmpInst::getSwappedPredicate(Pred); + } + + if (isa(RHS)) // fcmp pred X, undef -> undef + return UndefValue::get(GetCompareTy(LHS)); + + // fcmp x,x -> true/false. Not all compares are foldable. + if (LHS == RHS) { + if (CmpInst::isTrueWhenEqual(Pred)) + return ConstantInt::get(GetCompareTy(LHS), 1); + if (CmpInst::isFalseWhenEqual(Pred)) + return ConstantInt::get(GetCompareTy(LHS), 0); + } + + // Handle fcmp with constant RHS + if (Constant *RHSC = dyn_cast(RHS)) { + // If the constant is a nan, see if we can fold the comparison based on it. + if (ConstantFP *CFP = dyn_cast(RHSC)) { + if (CFP->getValueAPF().isNaN()) { + if (FCmpInst::isOrdered(Pred)) // True "if ordered and foo" + return ConstantInt::getFalse(CFP->getContext()); + assert(FCmpInst::isUnordered(Pred) && + "Comparison must be either ordered or unordered!"); + // True if unordered. + return ConstantInt::getTrue(CFP->getContext()); + } + } + } + return 0; } Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86627&r1=86626&r2=86627&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Nov 9 17:55:12 2009 @@ -5941,26 +5941,14 @@ } Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - - // Fold trivial predicates. - if (I.getPredicate() == FCmpInst::FCMP_FALSE) - return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 0)); - if (I.getPredicate() == FCmpInst::FCMP_TRUE) - return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1)); + if (Value *V = SimplifyFCmpInst(I.getPredicate(), Op0, Op1, TD)) + return ReplaceInstUsesWith(I, V); + // Simplify 'fcmp pred X, X' if (Op0 == Op1) { switch (I.getPredicate()) { default: llvm_unreachable("Unknown predicate!"); - case FCmpInst::FCMP_UEQ: // True if unordered or equal - case FCmpInst::FCMP_UGE: // True if unordered, greater than, or equal - case FCmpInst::FCMP_ULE: // True if unordered, less than, or equal - return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1)); - case FCmpInst::FCMP_OGT: // True if ordered and greater than - case FCmpInst::FCMP_OLT: // True if ordered and less than - case FCmpInst::FCMP_ONE: // True if ordered and operands are unequal - return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 0)); - case FCmpInst::FCMP_UNO: // True if unordered: isnan(X) | isnan(Y) case FCmpInst::FCMP_ULT: // True if unordered or less than case FCmpInst::FCMP_UGT: // True if unordered or greater than @@ -5981,23 +5969,8 @@ } } - if (isa(Op1)) // fcmp pred X, undef -> undef - return ReplaceInstUsesWith(I, UndefValue::get(I.getType())); - // Handle fcmp with constant RHS if (Constant *RHSC = dyn_cast(Op1)) { - // If the constant is a nan, see if we can fold the comparison based on it. - if (ConstantFP *CFP = dyn_cast(RHSC)) { - if (CFP->getValueAPF().isNaN()) { - if (FCmpInst::isOrdered(I.getPredicate())) // True if ordered and... - return ReplaceInstUsesWith(I, ConstantInt::getFalse(*Context)); - assert(FCmpInst::isUnordered(I.getPredicate()) && - "Comparison must be either ordered or unordered!"); - // True if unordered. - return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context)); - } - } - if (Instruction *LHSI = dyn_cast(Op0)) switch (LHSI->getOpcode()) { case Instruction::PHI: @@ -6055,25 +6028,12 @@ } Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); + + if (Value *V = SimplifyICmpInst(I.getPredicate(), Op0, Op1, TD)) + return ReplaceInstUsesWith(I, V); + const Type *Ty = Op0->getType(); - // icmp X, X - if (Op0 == Op1) - return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), - I.isTrueWhenEqual())); - - if (isa(Op1)) // X icmp undef -> undef - return ReplaceInstUsesWith(I, UndefValue::get(I.getType())); - - // icmp , - Global/Stack value - // addresses never equal each other! We already know that Op0 != Op1. - if ((isa(Op0) || isa(Op0) || - isa(Op0)) && - (isa(Op1) || isa(Op1) || - isa(Op1))) - return ReplaceInstUsesWith(I, ConstantInt::get(Type::getInt1Ty(*Context), - !I.isTrueWhenEqual())); - // icmp's with boolean values can always be turned into bitwise operations if (Ty == Type::getInt1Ty(*Context)) { switch (I.getPredicate()) { @@ -6137,27 +6097,24 @@ // If we have an icmp le or icmp ge instruction, turn it into the // appropriate icmp lt or icmp gt instruction. This allows us to rely on - // them being folded in the code below. + // them being folded in the code below. The SimplifyICmpInst code has + // already handled the edge cases for us, so we just assert on them. switch (I.getPredicate()) { default: break; case ICmpInst::ICMP_ULE: - if (CI->isMaxValue(false)) // A <=u MAX -> TRUE - return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context)); + assert(!CI->isMaxValue(false)); // A <=u MAX -> TRUE return new ICmpInst(ICmpInst::ICMP_ULT, Op0, AddOne(CI)); case ICmpInst::ICMP_SLE: - if (CI->isMaxValue(true)) // A <=s MAX -> TRUE - return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context)); + assert(!CI->isMaxValue(true)); // A <=s MAX -> TRUE return new ICmpInst(ICmpInst::ICMP_SLT, Op0, AddOne(CI)); case ICmpInst::ICMP_UGE: - if (CI->isMinValue(false)) // A >=u MIN -> TRUE - return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context)); + assert(!CI->isMinValue(false)); // A >=u MIN -> TRUE return new ICmpInst(ICmpInst::ICMP_UGT, Op0, SubOne(CI)); case ICmpInst::ICMP_SGE: - if (CI->isMinValue(true)) // A >=s MIN -> TRUE - return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context)); + assert(!CI->isMinValue(true)); // A >=s MIN -> TRUE return new ICmpInst(ICmpInst::ICMP_SGT, Op0, SubOne(CI)); } From david_goodwin at apple.com Mon Nov 9 18:15:47 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 10 Nov 2009 00:15:47 -0000 Subject: [llvm-commits] [llvm] r86628 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/X86/X86Subtarget.h Message-ID: <200911100015.nAA0FmdV007190@zion.cs.uiuc.edu> Author: david_goodwin Date: Mon Nov 9 18:15:47 2009 New Revision: 86628 URL: http://llvm.org/viewvc/llvm-project?rev=86628&view=rev Log: Allow targets to specify register classes whose member registers should not be renamed to break anti-dependencies. Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSubtarget.h?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSubtarget.h (original) +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Mon Nov 9 18:15:47 2009 @@ -15,6 +15,8 @@ #define LLVM_TARGET_TARGETSUBTARGET_H #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/ADT/SmallVector.h" namespace llvm { @@ -36,6 +38,7 @@ // AntiDepBreakMode - Type of anti-dependence breaking that should // be performed before post-RA scheduling. typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode; + typedef SmallVector ExcludedRCVector; virtual ~TargetSubtarget(); @@ -49,8 +52,10 @@ // scheduling and the specified optimization level meets the requirement // return true to enable post-register-allocation scheduling. virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, - AntiDepBreakMode& mode) const { - mode = ANTIDEP_NONE; + AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = ANTIDEP_NONE; + ExcludedRCs.clear(); return false; } Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Mon Nov 9 18:15:47 2009 @@ -99,12 +99,24 @@ AggressiveAntiDepBreaker:: -AggressiveAntiDepBreaker(MachineFunction& MFi) : +AggressiveAntiDepBreaker(MachineFunction& MFi, + TargetSubtarget::ExcludedRCVector& ExcludedRCs) : AntiDepBreaker(), MF(MFi), MRI(MF.getRegInfo()), TRI(MF.getTarget().getRegisterInfo()), AllocatableSet(TRI->getAllocatableSet(MF)), State(NULL), SavedState(NULL) { + /* Remove all registers from excluded RCs from the allocatable + register set. */ + for (unsigned i = 0, e = ExcludedRCs.size(); i < e; ++i) { + BitVector NotRenameable = TRI->getAllocatableSet(MF, ExcludedRCs[i]).flip(); + AllocatableSet &= NotRenameable; + } + + DEBUG(errs() << "AntiDep Renameable Registers:"); + DEBUG(for (int r = AllocatableSet.find_first(); r != -1; + r = AllocatableSet.find_next(r)) + errs() << " " << TRI->getName(r)); } AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() { Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Mon Nov 9 18:15:47 2009 @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/ScheduleDAG.h" +#include "llvm/Target/TargetSubtarget.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallSet.h" @@ -112,7 +113,7 @@ /// AllocatableSet - The set of allocatable registers. /// We'll be ignoring anti-dependencies on non-allocatable registers, /// because they may not be safe to break. - const BitVector AllocatableSet; + BitVector AllocatableSet; /// State - The state used to identify and rename anti-dependence /// registers. @@ -124,7 +125,8 @@ AggressiveAntiDepState *SavedState; public: - AggressiveAntiDepBreaker(MachineFunction& MFi); + AggressiveAntiDepBreaker(MachineFunction& MFi, + TargetSubtarget::ExcludedRCVector& ExcludedRCs); ~AggressiveAntiDepBreaker(); /// GetMaxTrials - As anti-dependencies are broken, additional Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Mon Nov 9 18:15:47 2009 @@ -216,13 +216,14 @@ // Check for explicit enable/disable of post-ra scheduling. TargetSubtarget::AntiDepBreakMode AntiDepMode = TargetSubtarget::ANTIDEP_NONE; + TargetSubtarget::ExcludedRCVector ExcludedRCs; if (EnablePostRAScheduler.getPosition() > 0) { if (!EnablePostRAScheduler) return false; } else { // Check that post-RA scheduling is enabled for this target. const TargetSubtarget &ST = Fn.getTarget().getSubtarget(); - if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode)) + if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, ExcludedRCs)) return false; } @@ -243,7 +244,7 @@ (ScheduleHazardRecognizer *)new SimpleHazardRecognizer(); AntiDepBreaker *ADB = ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ? - (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn) : + (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, ExcludedRCs) : ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ? (AntiDepBreaker *)new CriticalAntiDepBreaker(Fn) : NULL)); Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Nov 9 18:15:47 2009 @@ -17,6 +17,7 @@ #include "llvm/Target/TargetInstrItineraries.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtarget.h" +#include "ARMBaseRegisterInfo.h" #include namespace llvm { @@ -129,8 +130,11 @@ /// enablePostRAScheduler - True at 'More' optimization except /// for Thumb1. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, - TargetSubtarget::AntiDepBreakMode& mode) const { - mode = TargetSubtarget::ANTIDEP_CRITICAL; + TargetSubtarget::AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = TargetSubtarget::ANTIDEP_CRITICAL; + ExcludedRCs.clear(); + ExcludedRCs.push_back(&ARM::GPRRegClass); return PostRAScheduler && OptLevel >= CodeGenOpt::Default; } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=86628&r1=86627&r2=86628&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Nov 9 18:15:47 2009 @@ -219,8 +219,10 @@ /// enablePostRAScheduler - X86 target is enabling post-alloc scheduling /// at 'More' optimization level. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, - TargetSubtarget::AntiDepBreakMode& mode) const { - mode = TargetSubtarget::ANTIDEP_CRITICAL; + TargetSubtarget::AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = TargetSubtarget::ANTIDEP_CRITICAL; + ExcludedRCs.clear(); return OptLevel >= CodeGenOpt::Default; } }; From clattner at apple.com Mon Nov 9 18:25:33 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Nov 2009 16:25:33 -0800 Subject: [llvm-commits] [llvm] r86628 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/X86/X86Subtarget.h In-Reply-To: <200911100015.nAA0FmdV007190@zion.cs.uiuc.edu> References: <200911100015.nAA0FmdV007190@zion.cs.uiuc.edu> Message-ID: On Nov 9, 2009, at 4:15 PM, David Goodwin wrote: > Author: david_goodwin > Date: Mon Nov 9 18:15:47 2009 > New Revision: 86628 > > URL: http://llvm.org/viewvc/llvm-project?rev=86628&view=rev > Log: > Allow targets to specify register classes whose member registers > should not be renamed to break anti-dependencies. I don't have anything to say about the technical merits of this patch, but... > +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Mon Nov 9 > 18:15:47 2009 > @@ -15,6 +15,8 @@ > #define LLVM_TARGET_TARGETSUBTARGET_H > > #include "llvm/Target/TargetMachine.h" > +#include "llvm/Target/TargetRegisterInfo.h" > +#include "llvm/ADT/SmallVector.h" Please just forward declare what you need from these two headers instead of #including them. Also, for APIs that take a smallvector and fill it in, they should generally take a SmallVectorImpl instead of specifying a size (that way the client has the ability to pick a size). You can forward declare SmallVectorImpl like this: namespace llvm { template class SmallVectorImpl; } and move the virtual method out of line to avoid the .clear() in the header. Thanks David, -Chris > > namespace llvm { > > @@ -36,6 +38,7 @@ > // AntiDepBreakMode - Type of anti-dependence breaking that should > // be performed before post-RA scheduling. > typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } > AntiDepBreakMode; > + typedef SmallVector ExcludedRCVector; > > virtual ~TargetSubtarget(); > > @@ -49,8 +52,10 @@ > // scheduling and the specified optimization level meets the > requirement > // return true to enable post-register-allocation scheduling. > virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, > - AntiDepBreakMode& mode) const { > - mode = ANTIDEP_NONE; > + AntiDepBreakMode& Mode, > + ExcludedRCVector& ExcludedRCs) > const { > + Mode = ANTIDEP_NONE; > + ExcludedRCs.clear(); > return false; > } > > > Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86628&r1=86627&r2=86628&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) > +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Mon Nov 9 > 18:15:47 2009 > @@ -99,12 +99,24 @@ > > > AggressiveAntiDepBreaker:: > -AggressiveAntiDepBreaker(MachineFunction& MFi) : > +AggressiveAntiDepBreaker(MachineFunction& MFi, > + TargetSubtarget::ExcludedRCVector& > ExcludedRCs) : > AntiDepBreaker(), MF(MFi), > MRI(MF.getRegInfo()), > TRI(MF.getTarget().getRegisterInfo()), > AllocatableSet(TRI->getAllocatableSet(MF)), > State(NULL), SavedState(NULL) { > + /* Remove all registers from excluded RCs from the allocatable > + register set. */ > + for (unsigned i = 0, e = ExcludedRCs.size(); i < e; ++i) { > + BitVector NotRenameable = TRI->getAllocatableSet(MF, > ExcludedRCs[i]).flip(); > + AllocatableSet &= NotRenameable; > + } > + > + DEBUG(errs() << "AntiDep Renameable Registers:"); > + DEBUG(for (int r = AllocatableSet.find_first(); r != -1; > + r = AllocatableSet.find_next(r)) > + errs() << " " << TRI->getName(r)); > } > > AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() { > > Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=86628&r1=86627&r2=86628&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) > +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Mon Nov 9 > 18:15:47 2009 > @@ -23,6 +23,7 @@ > #include "llvm/CodeGen/MachineFunction.h" > #include "llvm/CodeGen/MachineRegisterInfo.h" > #include "llvm/CodeGen/ScheduleDAG.h" > +#include "llvm/Target/TargetSubtarget.h" > #include "llvm/Target/TargetRegisterInfo.h" > #include "llvm/ADT/BitVector.h" > #include "llvm/ADT/SmallSet.h" > @@ -112,7 +113,7 @@ > /// AllocatableSet - The set of allocatable registers. > /// We'll be ignoring anti-dependencies on non-allocatable > registers, > /// because they may not be safe to break. > - const BitVector AllocatableSet; > + BitVector AllocatableSet; > > /// State - The state used to identify and rename anti-dependence > /// registers. > @@ -124,7 +125,8 @@ > AggressiveAntiDepState *SavedState; > > public: > - AggressiveAntiDepBreaker(MachineFunction& MFi); > + AggressiveAntiDepBreaker(MachineFunction& MFi, > + TargetSubtarget::ExcludedRCVector& > ExcludedRCs); > ~AggressiveAntiDepBreaker(); > > /// GetMaxTrials - As anti-dependencies are broken, additional > > Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=86628&r1=86627&r2=86628&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) > +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Mon Nov 9 > 18:15:47 2009 > @@ -216,13 +216,14 @@ > > // Check for explicit enable/disable of post-ra scheduling. > TargetSubtarget::AntiDepBreakMode AntiDepMode = > TargetSubtarget::ANTIDEP_NONE; > + TargetSubtarget::ExcludedRCVector ExcludedRCs; > if (EnablePostRAScheduler.getPosition() > 0) { > if (!EnablePostRAScheduler) > return false; > } else { > // Check that post-RA scheduling is enabled for this target. > const TargetSubtarget &ST = > Fn.getTarget().getSubtarget(); > - if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode)) > + if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, > ExcludedRCs)) > return false; > } > > @@ -243,7 +244,7 @@ > (ScheduleHazardRecognizer *)new SimpleHazardRecognizer(); > AntiDepBreaker *ADB = > ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ? > - (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn) : > + (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, > ExcludedRCs) : > ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ? > (AntiDepBreaker *)new CriticalAntiDepBreaker(Fn) : NULL)); > > > Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=86628&r1=86627&r2=86628&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Nov 9 18:15:47 2009 > @@ -17,6 +17,7 @@ > #include "llvm/Target/TargetInstrItineraries.h" > #include "llvm/Target/TargetMachine.h" > #include "llvm/Target/TargetSubtarget.h" > +#include "ARMBaseRegisterInfo.h" > #include > > namespace llvm { > @@ -129,8 +130,11 @@ > /// enablePostRAScheduler - True at 'More' optimization except > /// for Thumb1. > bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, > - TargetSubtarget::AntiDepBreakMode& > mode) const { > - mode = TargetSubtarget::ANTIDEP_CRITICAL; > + TargetSubtarget::AntiDepBreakMode& Mode, > + ExcludedRCVector& ExcludedRCs) const { > + Mode = TargetSubtarget::ANTIDEP_CRITICAL; > + ExcludedRCs.clear(); > + ExcludedRCs.push_back(&ARM::GPRRegClass); > return PostRAScheduler && OptLevel >= CodeGenOpt::Default; > } > > > Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=86628&r1=86627&r2=86628&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) > +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Nov 9 18:15:47 2009 > @@ -219,8 +219,10 @@ > /// enablePostRAScheduler - X86 target is enabling post-alloc > scheduling > /// at 'More' optimization level. > bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, > - TargetSubtarget::AntiDepBreakMode& > mode) const { > - mode = TargetSubtarget::ANTIDEP_CRITICAL; > + TargetSubtarget::AntiDepBreakMode& Mode, > + ExcludedRCVector& ExcludedRCs) const { > + Mode = TargetSubtarget::ANTIDEP_CRITICAL; > + ExcludedRCs.clear(); > return OptLevel >= CodeGenOpt::Default; > } > }; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Mon Nov 9 18:43:59 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 00:43:59 -0000 Subject: [llvm-commits] [llvm] r86630 - in /llvm/trunk: include/llvm/Support/MemoryBuffer.h lib/Linker/LinkItems.cpp lib/Support/MemoryBuffer.cpp lib/VMCore/Core.cpp Message-ID: <200911100043.nAA0hxqW008252@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 18:43:58 2009 New Revision: 86630 URL: http://llvm.org/viewvc/llvm-project?rev=86630&view=rev Log: Fix MemoryBuffer::getSTDIN to *not* return null if stdin is empty, this is a lame API. Also, Stringrefify some more MemoryBuffer functions, and add two performance FIXMEs. Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h llvm/trunk/lib/Linker/LinkItems.cpp llvm/trunk/lib/Support/MemoryBuffer.cpp llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=86630&r1=86629&r2=86630&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original) +++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Mon Nov 9 18:43:58 2009 @@ -57,7 +57,7 @@ /// MemoryBuffer if successful, otherwise returning null. If FileSize is /// specified, this means that the client knows that the file exists and that /// it has the specified size. - static MemoryBuffer *getFile(const char *Filename, + static MemoryBuffer *getFile(StringRef Filename, std::string *ErrStr = 0, int64_t FileSize = -1); @@ -84,29 +84,18 @@ /// memory allocated by this method. The memory is owned by the MemoryBuffer /// object. static MemoryBuffer *getNewUninitMemBuffer(size_t Size, - const char *BufferName = ""); + StringRef BufferName = ""); - /// getSTDIN - Read all of stdin into a file buffer, and return it. This - /// returns null if stdin is empty. + /// getSTDIN - Read all of stdin into a file buffer, and return it. static MemoryBuffer *getSTDIN(); /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin /// if the Filename is "-". If an error occurs, this returns null and fills - /// in *ErrStr with a reason. If stdin is empty, this API (unlike getSTDIN) - /// returns an empty buffer. - static MemoryBuffer *getFileOrSTDIN(const char *Filename, - std::string *ErrStr = 0, - int64_t FileSize = -1); - - /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin - /// if the Filename is "-". If an error occurs, this returns null and fills /// in *ErrStr with a reason. - static MemoryBuffer *getFileOrSTDIN(const std::string &FN, + static MemoryBuffer *getFileOrSTDIN(StringRef Filename, std::string *ErrStr = 0, - int64_t FileSize = -1) { - return getFileOrSTDIN(FN.c_str(), ErrStr, FileSize); - } + int64_t FileSize = -1); }; } // end namespace llvm Modified: llvm/trunk/lib/Linker/LinkItems.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkItems.cpp?rev=86630&r1=86629&r2=86630&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkItems.cpp (original) +++ llvm/trunk/lib/Linker/LinkItems.cpp Mon Nov 9 18:43:58 2009 @@ -160,14 +160,17 @@ // Check for a file of name "-", which means "read standard input" if (File.str() == "-") { std::auto_ptr M; - if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN()) { + MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(); + if (!Buffer->getBufferSize()) { + delete Buffer; + Error = "standard input is empty"; + } else { M.reset(ParseBitcodeFile(Buffer, Context, &Error)); delete Buffer; if (M.get()) if (!LinkInModule(M.get(), &Error)) return false; - } else - Error = "standard input is empty"; + } return error("Cannot link stdin: " + Error); } Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=86630&r1=86629&r2=86630&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon Nov 9 18:43:58 2009 @@ -70,7 +70,7 @@ class MemoryBufferMem : public MemoryBuffer { std::string FileID; public: - MemoryBufferMem(const char *Start, const char *End, const char *FID, + MemoryBufferMem(const char *Start, const char *End, StringRef FID, bool Copy = false) : FileID(FID) { if (!Copy) @@ -107,7 +107,7 @@ /// initialize the memory allocated by this method. The memory is owned by /// the MemoryBuffer object. MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size, - const char *BufferName) { + StringRef BufferName) { char *Buf = (char *)malloc((Size+1) * sizeof(char)); if (!Buf) return 0; Buf[Size] = 0; @@ -134,17 +134,12 @@ /// if the Filename is "-". If an error occurs, this returns null and fills /// in *ErrStr with a reason. If stdin is empty, this API (unlike getSTDIN) /// returns an empty buffer. -MemoryBuffer *MemoryBuffer::getFileOrSTDIN(const char *Filename, +MemoryBuffer *MemoryBuffer::getFileOrSTDIN(StringRef Filename, std::string *ErrStr, int64_t FileSize) { - if (Filename[0] != '-' || Filename[1] != 0) - return getFile(Filename, ErrStr, FileSize); - MemoryBuffer *M = getSTDIN(); - if (M) return M; - - // If stdin was empty, M is null. Cons up an empty memory buffer now. - const char *EmptyStr = ""; - return MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, ""); + if (Filename == "-") + return getSTDIN(); + return getFile(Filename, ErrStr, FileSize); } //===----------------------------------------------------------------------===// @@ -158,7 +153,7 @@ class MemoryBufferMMapFile : public MemoryBuffer { std::string Filename; public: - MemoryBufferMMapFile(const char *filename, const char *Pages, uint64_t Size) + MemoryBufferMMapFile(StringRef filename, const char *Pages, uint64_t Size) : Filename(filename) { init(Pages, Pages+Size); } @@ -173,13 +168,13 @@ }; } -MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr, +MemoryBuffer *MemoryBuffer::getFile(StringRef Filename, std::string *ErrStr, int64_t FileSize) { int OpenFlags = 0; #ifdef O_BINARY OpenFlags |= O_BINARY; // Open input file in binary mode on win32. #endif - int FD = ::open(Filename, O_RDONLY|OpenFlags); + int FD = ::open(Filename.str().c_str(), O_RDONLY|OpenFlags); if (FD == -1) { if (ErrStr) *ErrStr = "could not open file"; return 0; @@ -203,6 +198,8 @@ // for small files, because this can severely fragment our address space. Also // don't try to map files that are exactly a multiple of the system page size, // as the file would not have the required null terminator. + // + // FIXME: Can we just mmap an extra page in the latter case? if (FileSize >= 4096*4 && (FileSize & (sys::Process::GetPageSize()-1)) != 0) { if (const char *Pages = sys::Path::MapInFilePages(FD, FileSize)) { @@ -262,6 +259,9 @@ std::vector FileData; // Read in all of the data from stdin, we cannot mmap stdin. + // + // FIXME: That isn't necessarily true, we should try to mmap stdin and + // fallback if it fails. sys::Program::ChangeStdinToBinary(); size_t ReadBytes; do { @@ -271,8 +271,6 @@ FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end(). size_t Size = FileData.size(); - if (Size <= 1) - return 0; MemoryBuffer *B = new STDINBufferFile(); B->initCopyOf(&FileData[0], &FileData[Size-1]); return B; Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=86630&r1=86629&r2=86630&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Nov 9 18:43:58 2009 @@ -1987,13 +1987,15 @@ int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage) { - if (MemoryBuffer *MB = MemoryBuffer::getSTDIN()) { - *OutMemBuf = wrap(MB); - return 0; + MemoryBuffer *MB = MemoryBuffer::getSTDIN(); + if (!MB->getBufferSize()) { + delete MB; + *OutMessage = strdup("stdin is empty."); + return 1; } - - *OutMessage = strdup("stdin is empty."); - return 1; + + *OutMemBuf = wrap(MB); + return 0; } void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) { From david_goodwin at apple.com Mon Nov 9 18:48:56 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 10 Nov 2009 00:48:56 -0000 Subject: [llvm-commits] [llvm] r86634 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/TargetSubtarget.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h Message-ID: <200911100048.nAA0mubl008579@zion.cs.uiuc.edu> Author: david_goodwin Date: Mon Nov 9 18:48:55 2009 New Revision: 86634 URL: http://llvm.org/viewvc/llvm-project?rev=86634&view=rev Log: Fixed to address code review. No functional changes. Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/TargetSubtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSubtarget.h?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSubtarget.h (original) +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Mon Nov 9 18:48:55 2009 @@ -15,13 +15,13 @@ #define LLVM_TARGET_TARGETSUBTARGET_H #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/ADT/SmallVector.h" namespace llvm { class SDep; class SUnit; +class TargetRegisterClass; +template class SmallVectorImpl; //===----------------------------------------------------------------------===// /// @@ -38,7 +38,7 @@ // AntiDepBreakMode - Type of anti-dependence breaking that should // be performed before post-RA scheduling. typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode; - typedef SmallVector ExcludedRCVector; + typedef SmallVectorImpl ExcludedRCVector; virtual ~TargetSubtarget(); @@ -53,12 +53,7 @@ // return true to enable post-register-allocation scheduling. virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { - Mode = ANTIDEP_NONE; - ExcludedRCs.clear(); - return false; - } - + ExcludedRCVector& ExcludedRCs) const; // adjustSchedDependency - Perform target specific adjustments to // the latency of a schedule dependency. virtual void adjustSchedDependency(SUnit *def, SUnit *use, Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Mon Nov 9 18:48:55 2009 @@ -216,7 +216,7 @@ // Check for explicit enable/disable of post-ra scheduling. TargetSubtarget::AntiDepBreakMode AntiDepMode = TargetSubtarget::ANTIDEP_NONE; - TargetSubtarget::ExcludedRCVector ExcludedRCs; + SmallVector ExcludedRCs; if (EnablePostRAScheduler.getPosition() > 0) { if (!EnablePostRAScheduler) return false; Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Mon Nov 9 18:48:55 2009 @@ -16,6 +16,7 @@ #include "llvm/GlobalValue.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/CommandLine.h" +#include "llvm/ADT/SmallVector.h" using namespace llvm; static cl::opt @@ -159,3 +160,13 @@ return false; } + +bool ARMSubtarget::enablePostRAScheduler( + CodeGenOpt::Level OptLevel, + TargetSubtarget::AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = TargetSubtarget::ANTIDEP_CRITICAL; + ExcludedRCs.clear(); + ExcludedRCs.push_back(&ARM::GPRRegClass); + return PostRAScheduler && OptLevel >= CodeGenOpt::Default; +} Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Nov 9 18:48:55 2009 @@ -127,16 +127,10 @@ const std::string & getCPUString() const { return CPUString; } - /// enablePostRAScheduler - True at 'More' optimization except - /// for Thumb1. + /// enablePostRAScheduler - True at 'More' optimization. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { - Mode = TargetSubtarget::ANTIDEP_CRITICAL; - ExcludedRCs.clear(); - ExcludedRCs.push_back(&ARM::GPRRegClass); - return PostRAScheduler && OptLevel >= CodeGenOpt::Default; - } + ExcludedRCVector& ExcludedRCs) const; /// getInstrItins - Return the instruction itineraies based on subtarget /// selection. Modified: llvm/trunk/lib/Target/TargetSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetSubtarget.cpp?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetSubtarget.cpp (original) +++ llvm/trunk/lib/Target/TargetSubtarget.cpp Mon Nov 9 18:48:55 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetSubtarget.h" +#include "llvm/ADT/SmallVector.h" using namespace llvm; //--------------------------------------------------------------------------- @@ -20,3 +21,13 @@ TargetSubtarget::TargetSubtarget() {} TargetSubtarget::~TargetSubtarget() {} + +bool TargetSubtarget::enablePostRAScheduler( + CodeGenOpt::Level OptLevel, + AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = ANTIDEP_NONE; + ExcludedRCs.clear(); + return false; +} + Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon Nov 9 18:48:55 2009 @@ -20,6 +20,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/ADT/SmallVector.h" using namespace llvm; #if defined(_MSC_VER) @@ -455,3 +456,12 @@ if (StackAlignment) stackAlignment = StackAlignment; } + +bool X86Subtarget::enablePostRAScheduler( + CodeGenOpt::Level OptLevel, + TargetSubtarget::AntiDepBreakMode& Mode, + ExcludedRCVector& ExcludedRCs) const { + Mode = TargetSubtarget::ANTIDEP_CRITICAL; + ExcludedRCs.clear(); + return OptLevel >= CodeGenOpt::Default; +} Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=86634&r1=86633&r2=86634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Nov 9 18:48:55 2009 @@ -220,11 +220,7 @@ /// at 'More' optimization level. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { - Mode = TargetSubtarget::ANTIDEP_CRITICAL; - ExcludedRCs.clear(); - return OptLevel >= CodeGenOpt::Default; - } + ExcludedRCVector& ExcludedRCs) const; }; } // End llvm namespace From david_goodwin at apple.com Mon Nov 9 18:52:00 2009 From: david_goodwin at apple.com (David Goodwin) Date: Mon, 9 Nov 2009 16:52:00 -0800 Subject: [llvm-commits] [llvm] r86628 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/X86/X86Subtarget.h In-Reply-To: References: <200911100015.nAA0FmdV007190@zion.cs.uiuc.edu> Message-ID: <80411469-B27A-4B78-968B-D60C7DB43BDF@apple.com> r86634 On Nov 9, 2009, at 4:25 PM, Chris Lattner wrote: > > On Nov 9, 2009, at 4:15 PM, David Goodwin wrote: > >> Author: david_goodwin >> Date: Mon Nov 9 18:15:47 2009 >> New Revision: 86628 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86628&view=rev >> Log: >> Allow targets to specify register classes whose member registers >> should not be renamed to break anti-dependencies. > > I don't have anything to say about the technical merits of this > patch, but... > >> +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Mon Nov 9 >> 18:15:47 2009 >> @@ -15,6 +15,8 @@ >> #define LLVM_TARGET_TARGETSUBTARGET_H >> >> #include "llvm/Target/TargetMachine.h" >> +#include "llvm/Target/TargetRegisterInfo.h" >> +#include "llvm/ADT/SmallVector.h" > > Please just forward declare what you need from these two headers > instead of #including them. Also, for APIs that take a smallvector > and fill it in, they should generally take a SmallVectorImpl > instead of specifying a size (that way the client has the ability to > pick a size). You can forward declare SmallVectorImpl like this: > > namespace llvm { > template class SmallVectorImpl; > } > > and move the virtual method out of line to avoid the .clear() in the > header. > > Thanks David, > > -Chris > >> >> namespace llvm { >> >> @@ -36,6 +38,7 @@ >> // AntiDepBreakMode - Type of anti-dependence breaking that should >> // be performed before post-RA scheduling. >> typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } >> AntiDepBreakMode; >> + typedef SmallVector ExcludedRCVector; >> >> virtual ~TargetSubtarget(); >> >> @@ -49,8 +52,10 @@ >> // scheduling and the specified optimization level meets the >> requirement >> // return true to enable post-register-allocation scheduling. >> virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, >> - AntiDepBreakMode& mode) const { >> - mode = ANTIDEP_NONE; >> + AntiDepBreakMode& Mode, >> + ExcludedRCVector& >> ExcludedRCs) const { >> + Mode = ANTIDEP_NONE; >> + ExcludedRCs.clear(); >> return false; >> } >> >> >> Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86628&r1=86627&r2=86628&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) >> +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Mon Nov 9 >> 18:15:47 2009 >> @@ -99,12 +99,24 @@ >> >> >> AggressiveAntiDepBreaker:: >> -AggressiveAntiDepBreaker(MachineFunction& MFi) : >> +AggressiveAntiDepBreaker(MachineFunction& MFi, >> + TargetSubtarget::ExcludedRCVector& >> ExcludedRCs) : >> AntiDepBreaker(), MF(MFi), >> MRI(MF.getRegInfo()), >> TRI(MF.getTarget().getRegisterInfo()), >> AllocatableSet(TRI->getAllocatableSet(MF)), >> State(NULL), SavedState(NULL) { >> + /* Remove all registers from excluded RCs from the allocatable >> + register set. */ >> + for (unsigned i = 0, e = ExcludedRCs.size(); i < e; ++i) { >> + BitVector NotRenameable = TRI->getAllocatableSet(MF, >> ExcludedRCs[i]).flip(); >> + AllocatableSet &= NotRenameable; >> + } >> + >> + DEBUG(errs() << "AntiDep Renameable Registers:"); >> + DEBUG(for (int r = AllocatableSet.find_first(); r != -1; >> + r = AllocatableSet.find_next(r)) >> + errs() << " " << TRI->getName(r)); >> } >> >> AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() { >> >> Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=86628&r1=86627&r2=86628&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) >> +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Mon Nov 9 >> 18:15:47 2009 >> @@ -23,6 +23,7 @@ >> #include "llvm/CodeGen/MachineFunction.h" >> #include "llvm/CodeGen/MachineRegisterInfo.h" >> #include "llvm/CodeGen/ScheduleDAG.h" >> +#include "llvm/Target/TargetSubtarget.h" >> #include "llvm/Target/TargetRegisterInfo.h" >> #include "llvm/ADT/BitVector.h" >> #include "llvm/ADT/SmallSet.h" >> @@ -112,7 +113,7 @@ >> /// AllocatableSet - The set of allocatable registers. >> /// We'll be ignoring anti-dependencies on non-allocatable >> registers, >> /// because they may not be safe to break. >> - const BitVector AllocatableSet; >> + BitVector AllocatableSet; >> >> /// State - The state used to identify and rename anti-dependence >> /// registers. >> @@ -124,7 +125,8 @@ >> AggressiveAntiDepState *SavedState; >> >> public: >> - AggressiveAntiDepBreaker(MachineFunction& MFi); >> + AggressiveAntiDepBreaker(MachineFunction& MFi, >> + TargetSubtarget::ExcludedRCVector& >> ExcludedRCs); >> ~AggressiveAntiDepBreaker(); >> >> /// GetMaxTrials - As anti-dependencies are broken, additional >> >> Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=86628&r1=86627&r2=86628&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) >> +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Mon Nov 9 >> 18:15:47 2009 >> @@ -216,13 +216,14 @@ >> >> // Check for explicit enable/disable of post-ra scheduling. >> TargetSubtarget::AntiDepBreakMode AntiDepMode = >> TargetSubtarget::ANTIDEP_NONE; >> + TargetSubtarget::ExcludedRCVector ExcludedRCs; >> if (EnablePostRAScheduler.getPosition() > 0) { >> if (!EnablePostRAScheduler) >> return false; >> } else { >> // Check that post-RA scheduling is enabled for this target. >> const TargetSubtarget &ST = Fn.getTarget >> ().getSubtarget(); >> - if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode)) >> + if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, >> ExcludedRCs)) >> return false; >> } >> >> @@ -243,7 +244,7 @@ >> (ScheduleHazardRecognizer *)new SimpleHazardRecognizer(); >> AntiDepBreaker *ADB = >> ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ? >> - (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn) : >> + (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, >> ExcludedRCs) : >> ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ? >> (AntiDepBreaker *)new CriticalAntiDepBreaker(Fn) : NULL)); >> >> >> Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=86628&r1=86627&r2=86628&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) >> +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Nov 9 18:15:47 2009 >> @@ -17,6 +17,7 @@ >> #include "llvm/Target/TargetInstrItineraries.h" >> #include "llvm/Target/TargetMachine.h" >> #include "llvm/Target/TargetSubtarget.h" >> +#include "ARMBaseRegisterInfo.h" >> #include >> >> namespace llvm { >> @@ -129,8 +130,11 @@ >> /// enablePostRAScheduler - True at 'More' optimization except >> /// for Thumb1. >> bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, >> - TargetSubtarget::AntiDepBreakMode& >> mode) const { >> - mode = TargetSubtarget::ANTIDEP_CRITICAL; >> + TargetSubtarget::AntiDepBreakMode& >> Mode, >> + ExcludedRCVector& ExcludedRCs) const { >> + Mode = TargetSubtarget::ANTIDEP_CRITICAL; >> + ExcludedRCs.clear(); >> + ExcludedRCs.push_back(&ARM::GPRRegClass); >> return PostRAScheduler && OptLevel >= CodeGenOpt::Default; >> } >> >> >> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=86628&r1=86627&r2=86628&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) >> +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Nov 9 18:15:47 2009 >> @@ -219,8 +219,10 @@ >> /// enablePostRAScheduler - X86 target is enabling post-alloc >> scheduling >> /// at 'More' optimization level. >> bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, >> - TargetSubtarget::AntiDepBreakMode& >> mode) const { >> - mode = TargetSubtarget::ANTIDEP_CRITICAL; >> + TargetSubtarget::AntiDepBreakMode& >> Mode, >> + ExcludedRCVector& ExcludedRCs) const { >> + Mode = TargetSubtarget::ANTIDEP_CRITICAL; >> + ExcludedRCs.clear(); >> return OptLevel >= CodeGenOpt::Default; >> } >> }; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Mon Nov 9 18:55:13 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 00:55:13 -0000 Subject: [llvm-commits] [llvm] r86635 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911100055.nAA0tDln008794@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 18:55:12 2009 New Revision: 86635 URL: http://llvm.org/viewvc/llvm-project?rev=86635&view=rev Log: factor simplification logic for AND and OR out to InstSimplify from instcombine. Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86635&r1=86634&r2=86635&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original) +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Mon Nov 9 18:55:12 2009 @@ -20,15 +20,26 @@ class Value; class TargetData; + + /// SimplifyAndInst - Given operands for an And, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyAndInst(Value *LHS, Value *RHS, + const TargetData *TD = 0); + + /// SimplifyOrInst - Given operands for an Or, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyOrInst(Value *LHS, Value *RHS, + const TargetData *TD = 0); + /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can /// fold the result. If not, this returns null. Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, - const TargetData *TD = 0); + const TargetData *TD = 0); /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can /// fold the result. If not, this returns null. Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, - const TargetData *TD = 0); + const TargetData *TD = 0); //=== Helper functions for higher up the class hierarchy. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86635&r1=86634&r2=86635&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 18:55:12 2009 @@ -16,21 +16,133 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Instructions.h" +#include "llvm/Support/PatternMatch.h" using namespace llvm; +using namespace llvm::PatternMatch; +/// SimplifyAndInst - Given operands for an And, see if we can +/// fold the result. If not, this returns null. +Value *llvm::SimplifyAndInst(Value *Op0, Value *Op1, + const TargetData *TD) { + if (Constant *CLHS = dyn_cast(Op0)) { + if (Constant *CRHS = dyn_cast(Op1)) { + Constant *Ops[] = { CLHS, CRHS }; + return ConstantFoldInstOperands(Instruction::And, CLHS->getType(), + Ops, 2, TD); + } + + // Canonicalize the constant to the RHS. + std::swap(Op0, Op1); + } + + // X & undef -> 0 + if (isa(Op1)) + return Constant::getNullValue(Op0->getType()); + + // X & X = X + if (Op0 == Op1) + return Op0; + + // X & <0,0> = <0,0> + if (isa(Op1)) + return Op1; + + // X & <-1,-1> = X + if (ConstantVector *CP = dyn_cast(Op1)) + if (CP->isAllOnesValue()) + return Op0; + + if (ConstantInt *Op1CI = dyn_cast(Op1)) { + // X & 0 = 0 + if (Op1CI->isZero()) + return Op1CI; + // X & -1 = X + if (Op1CI->isAllOnesValue()) + return Op0; + } + + // A & ~A = ~A & A = 0 + Value *A, *B; + if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || + (match(Op1, m_Not(m_Value(A))) && A == Op0)) + return Constant::getNullValue(Op0->getType()); + + // (A | ?) & A = A + if (match(Op0, m_Or(m_Value(A), m_Value(B))) && + (A == Op1 || B == Op1)) + return Op1; + + // A & (A | ?) = A + if (match(Op1, m_Or(m_Value(A), m_Value(B))) && + (A == Op0 || B == Op0)) + return Op0; + + return 0; +} -/// SimplifyBinOp - Given operands for a BinaryOperator, see if we can +/// SimplifyOrInst - Given operands for an Or, see if we can /// fold the result. If not, this returns null. -Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, - const TargetData *TD) { - if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) { - Constant *COps[] = {CLHS, CRHS}; - return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, 2, TD); - } +Value *llvm::SimplifyOrInst(Value *Op0, Value *Op1, + const TargetData *TD) { + if (Constant *CLHS = dyn_cast(Op0)) { + if (Constant *CRHS = dyn_cast(Op1)) { + Constant *Ops[] = { CLHS, CRHS }; + return ConstantFoldInstOperands(Instruction::Or, CLHS->getType(), + Ops, 2, TD); + } + + // Canonicalize the constant to the RHS. + std::swap(Op0, Op1); + } + + // X | undef -> -1 + if (isa(Op1)) + return Constant::getAllOnesValue(Op0->getType()); + + // X | X = X + if (Op0 == Op1) + return Op0; + + // X | <0,0> = X + if (isa(Op1)) + return Op0; + + // X | <-1,-1> = <-1,-1> + if (ConstantVector *CP = dyn_cast(Op1)) + if (CP->isAllOnesValue()) + return Op1; + + if (ConstantInt *Op1CI = dyn_cast(Op1)) { + // X | 0 = X + if (Op1CI->isZero()) + return Op0; + // X | -1 = -1 + if (Op1CI->isAllOnesValue()) + return Op1CI; + } + + // A | ~A = ~A | A = -1 + Value *A, *B; + if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || + (match(Op1, m_Not(m_Value(A))) && A == Op0)) + return Constant::getAllOnesValue(Op0->getType()); + + // (A & ?) | A = A + if (match(Op0, m_And(m_Value(A), m_Value(B))) && + (A == Op1 || B == Op1)) + return Op1; + + // A | (A & ?) = A + if (match(Op1, m_And(m_Value(A), m_Value(B))) && + (A == Op0 || B == Op0)) + return Op0; + return 0; } + + + static const Type *GetCompareTy(Value *Op) { return CmpInst::makeCmpResultType(Op->getType()); } @@ -43,9 +155,14 @@ CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; assert(CmpInst::isIntPredicate(Pred) && "Not an integer compare!"); - if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CLHS = dyn_cast(LHS)) { if (Constant *CRHS = dyn_cast(RHS)) return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); + + // If we have a constant, make sure it is on the RHS. + std::swap(LHS, RHS); + Pred = CmpInst::getSwappedPredicate(Pred); + } // ITy - This is the return type of the compare we're considering. const Type *ITy = GetCompareTy(LHS); @@ -54,12 +171,6 @@ if (LHS == RHS) return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred)); - // If we have a constant, make sure it is on the RHS. - if (isa(LHS)) { - std::swap(LHS, RHS); - Pred = CmpInst::getSwappedPredicate(Pred); - } - if (isa(RHS)) // X icmp undef -> undef return UndefValue::get(ITy); @@ -95,8 +206,6 @@ return ConstantInt::getTrue(CI->getContext()); break; } - - } @@ -110,9 +219,14 @@ CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; assert(CmpInst::isFPPredicate(Pred) && "Not an FP compare!"); - if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CLHS = dyn_cast(LHS)) { if (Constant *CRHS = dyn_cast(RHS)) return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, TD); + + // If we have a constant, make sure it is on the RHS. + std::swap(LHS, RHS); + Pred = CmpInst::getSwappedPredicate(Pred); + } // Fold trivial predicates. if (Pred == FCmpInst::FCMP_FALSE) @@ -120,12 +234,6 @@ if (Pred == FCmpInst::FCMP_TRUE) return ConstantInt::get(GetCompareTy(LHS), 1); - // If we have a constant, make sure it is on the RHS. - if (isa(LHS)) { - std::swap(LHS, RHS); - Pred = CmpInst::getSwappedPredicate(Pred); - } - if (isa(RHS)) // fcmp pred X, undef -> undef return UndefValue::get(GetCompareTy(LHS)); @@ -155,7 +263,24 @@ return 0; } +//=== Helper functions for higher up the class hierarchy. +/// SimplifyBinOp - Given operands for a BinaryOperator, see if we can +/// fold the result. If not, this returns null. +Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, + const TargetData *TD) { + switch (Opcode) { + case Instruction::And: return SimplifyAndInst(LHS, RHS, TD); + case Instruction::Or: return SimplifyOrInst(LHS, RHS, TD); + default: + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) { + Constant *COps[] = {CLHS, CRHS}; + return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, 2, TD); + } + return 0; + } +} /// SimplifyCmpInst - Given operands for a CmpInst, see if we can /// fold the result. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86635&r1=86634&r2=86635&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Nov 9 18:55:12 2009 @@ -4292,25 +4292,15 @@ bool Changed = SimplifyCommutative(I); Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (isa(Op1)) // X & undef -> 0 - return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - - // and X, X = X - if (Op0 == Op1) - return ReplaceInstUsesWith(I, Op1); + if (Value *V = SimplifyAndInst(Op0, Op1, TD)) + return ReplaceInstUsesWith(I, V); + // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. if (SimplifyDemandedInstructionBits(I)) return &I; - if (isa(I.getType())) { - if (ConstantVector *CP = dyn_cast(Op1)) { - if (CP->isAllOnesValue()) // X & <-1,-1> -> X - return ReplaceInstUsesWith(I, I.getOperand(0)); - } else if (isa(Op1)) { - return ReplaceInstUsesWith(I, Op1); // X & <0,0> -> <0,0> - } - } + if (ConstantInt *AndRHS = dyn_cast(Op1)) { const APInt &AndRHSMask = AndRHS->getValue(); @@ -4431,42 +4421,29 @@ return NV; } - Value *Op0NotVal = dyn_castNotVal(Op0); - Value *Op1NotVal = dyn_castNotVal(Op1); - - if (Op0NotVal == Op1 || Op1NotVal == Op0) // A & ~A == ~A & A == 0 - return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); // (~A & ~B) == (~(A | B)) - De Morgan's Law - if (Op0NotVal && Op1NotVal && isOnlyUse(Op0) && isOnlyUse(Op1)) { - Value *Or = Builder->CreateOr(Op0NotVal, Op1NotVal, - I.getName()+".demorgan"); - return BinaryOperator::CreateNot(Or); - } - + if (Value *Op0NotVal = dyn_castNotVal(Op0)) + if (Value *Op1NotVal = dyn_castNotVal(Op1)) + if (Op0->hasOneUse() && Op1->hasOneUse()) { + Value *Or = Builder->CreateOr(Op0NotVal, Op1NotVal, + I.getName()+".demorgan"); + return BinaryOperator::CreateNot(Or); + } + { Value *A = 0, *B = 0, *C = 0, *D = 0; - if (match(Op0, m_Or(m_Value(A), m_Value(B)))) { - if (A == Op1 || B == Op1) // (A | ?) & A --> A - return ReplaceInstUsesWith(I, Op1); - - // (A|B) & ~(A&B) -> A^B - if (match(Op1, m_Not(m_And(m_Value(C), m_Value(D))))) { - if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::CreateXor(A, B); - } - } + // (A|B) & ~(A&B) -> A^B + if (match(Op0, m_Or(m_Value(A), m_Value(B))) && + match(Op1, m_Not(m_And(m_Value(C), m_Value(D)))) && + ((A == C && B == D) || (A == D && B == C))) + return BinaryOperator::CreateXor(A, B); - if (match(Op1, m_Or(m_Value(A), m_Value(B)))) { - if (A == Op0 || B == Op0) // A & (A | ?) --> A - return ReplaceInstUsesWith(I, Op0); - - // ~(A&B) & (A|B) -> A^B - if (match(Op0, m_Not(m_And(m_Value(C), m_Value(D))))) { - if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::CreateXor(A, B); - } - } + // ~(A&B) & (A|B) -> A^B + if (match(Op1, m_Or(m_Value(A), m_Value(B))) && + match(Op0, m_Not(m_And(m_Value(C), m_Value(D)))) && + ((A == C && B == D) || (A == D && B == C))) + return BinaryOperator::CreateXor(A, B); if (Op0->hasOneUse() && match(Op0, m_Xor(m_Value(A), m_Value(B)))) { @@ -4998,27 +4975,15 @@ bool Changed = SimplifyCommutative(I); Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (isa(Op1)) // X | undef -> -1 - return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType())); - - // or X, X = X - if (Op0 == Op1) - return ReplaceInstUsesWith(I, Op0); - + if (Value *V = SimplifyOrInst(Op0, Op1, TD)) + return ReplaceInstUsesWith(I, V); + + // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. if (SimplifyDemandedInstructionBits(I)) return &I; - if (isa(I.getType())) { - if (isa(Op1)) { - return ReplaceInstUsesWith(I, Op0); // X | <0,0> -> X - } else if (ConstantVector *CP = dyn_cast(Op1)) { - if (CP->isAllOnesValue()) // X | <-1,-1> -> <-1,-1> - return ReplaceInstUsesWith(I, I.getOperand(1)); - } - } - // or X, -1 == -1 if (ConstantInt *RHS = dyn_cast(Op1)) { ConstantInt *C1 = 0; Value *X = 0; // (X & C1) | C2 --> (X | C2) & (C1|C2) @@ -5051,13 +5016,6 @@ Value *A = 0, *B = 0; ConstantInt *C1 = 0, *C2 = 0; - if (match(Op0, m_And(m_Value(A), m_Value(B)))) - if (A == Op1 || B == Op1) // (A & ?) | A --> A - return ReplaceInstUsesWith(I, Op1); - if (match(Op1, m_And(m_Value(A), m_Value(B)))) - if (A == Op0 || B == Op0) // A | (A & ?) --> A - return ReplaceInstUsesWith(I, Op0); - // (A | B) | C and A | (B | C) -> bswap if possible. // (A >> B) | (C << D) and (A << B) | (B >> C) -> bswap if possible. if (match(Op0, m_Or(m_Value(), m_Value())) || @@ -5191,23 +5149,14 @@ if (Ret) return Ret; } - if ((A = dyn_castNotVal(Op0))) { // ~A | Op1 - if (A == Op1) // ~A | A == -1 - return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType())); - } else { - A = 0; - } - // Note, A is still live here! - if ((B = dyn_castNotVal(Op1))) { // Op0 | ~B - if (Op0 == B) - return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType())); - - // (~A | ~B) == (~(A & B)) - De Morgan's Law - if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) { - Value *And = Builder->CreateAnd(A, B, I.getName()+".demorgan"); - return BinaryOperator::CreateNot(And); - } - } + // (~A | ~B) == (~(A & B)) - De Morgan's Law + if (Value *Op0NotVal = dyn_castNotVal(Op0)) + if (Value *Op1NotVal = dyn_castNotVal(Op1)) + if (Op0->hasOneUse() && Op1->hasOneUse()) { + Value *And = Builder->CreateAnd(Op0NotVal, Op1NotVal, + I.getName()+".demorgan"); + return BinaryOperator::CreateNot(And); + } // (icmp1 A, B) | (icmp2 A, B) --> (icmp3 A, B) if (ICmpInst *RHS = dyn_cast(I.getOperand(1))) { From jyasskin at google.com Mon Nov 9 19:02:18 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 10 Nov 2009 01:02:18 -0000 Subject: [llvm-commits] [llvm] r86636 - in /llvm/trunk: include/llvm/ADT/DenseMap.h include/llvm/Analysis/SparsePropagation.h include/llvm/Support/type_traits.h lib/Analysis/IPA/Andersens.cpp lib/CodeGen/AsmPrinter/DwarfException.cpp lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/SlotIndexes.cpp lib/Target/MSP430/MSP430ISelDAGToDAG.cpp lib/Target/X86/X86InstrInfo.cpp lib/Transforms/Scalar/ABCD.cpp lib/Transforms/Scalar/GVN.cpp lib/Transforms/Scalar/SCCVN.cpp lib/VMCore/Metadata.cpp unittests/ADT/DenseMapTest.cpp Message-ID: <200911100102.nAA12ITk009096@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Nov 9 19:02:17 2009 New Revision: 86636 URL: http://llvm.org/viewvc/llvm-project?rev=86636&view=rev Log: Fix DenseMap iterator constness. This patch forbids implicit conversion of DenseMap::const_iterator to DenseMap::iterator which was possible because DenseMapIterator inherited (publicly) from DenseMapConstIterator. Conversion the other way around is now allowed as one may expect. The template DenseMapConstIterator is removed and the template parameter IsConst which specifies whether the iterator is constant is added to DenseMapIterator. Actually IsConst parameter is not necessary since the constness can be determined from KeyT but this is not relevant to the fix and can be addressed later. Patch by Victor Zverovich! Modified: llvm/trunk/include/llvm/ADT/DenseMap.h llvm/trunk/include/llvm/Analysis/SparsePropagation.h llvm/trunk/include/llvm/Support/type_traits.h llvm/trunk/lib/Analysis/IPA/Andersens.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/SlotIndexes.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Transforms/Scalar/ABCD.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp llvm/trunk/lib/VMCore/Metadata.cpp llvm/trunk/unittests/ADT/DenseMapTest.cpp Modified: llvm/trunk/include/llvm/ADT/DenseMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMap.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMap.h Mon Nov 9 19:02:17 2009 @@ -14,8 +14,9 @@ #ifndef LLVM_ADT_DENSEMAP_H #define LLVM_ADT_DENSEMAP_H -#include "llvm/Support/PointerLikeTypeTraits.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/PointerLikeTypeTraits.h" +#include "llvm/Support/type_traits.h" #include "llvm/ADT/DenseMapInfo.h" #include #include @@ -27,12 +28,8 @@ template, - typename ValueInfoT = DenseMapInfo > + typename ValueInfoT = DenseMapInfo, bool IsConst = false> class DenseMapIterator; -template, - typename ValueInfoT = DenseMapInfo > -class DenseMapConstIterator; template, @@ -73,7 +70,8 @@ } typedef DenseMapIterator iterator; - typedef DenseMapConstIterator const_iterator; + typedef DenseMapIterator const_iterator; inline iterator begin() { return iterator(Buckets, Buckets+NumBuckets); } @@ -426,32 +424,47 @@ } }; -template -class DenseMapIterator : - public std::iterator, - ptrdiff_t> { - typedef std::pair BucketT; -protected: - const BucketT *Ptr, *End; +template +class DenseMapIterator { + typedef std::pair Bucket; + typedef DenseMapIterator ConstIterator; + friend class DenseMapIterator; +public: + typedef ptrdiff_t difference_type; + typedef typename conditional::type value_type; + typedef value_type *pointer; + typedef value_type &reference; + typedef std::forward_iterator_tag iterator_category; +private: + pointer Ptr, End; public: DenseMapIterator() : Ptr(0), End(0) {} - DenseMapIterator(const BucketT *Pos, const BucketT *E) : Ptr(Pos), End(E) { + DenseMapIterator(pointer Pos, pointer E) : Ptr(Pos), End(E) { AdvancePastEmptyBuckets(); } - std::pair &operator*() const { - return *const_cast(Ptr); + // If IsConst is true this is a converting constructor from iterator to + // const_iterator and the default copy constructor is used. + // Otherwise this is a copy constructor for iterator. + DenseMapIterator(const DenseMapIterator& I) + : Ptr(I.Ptr), End(I.End) {} + + reference operator*() const { + return *Ptr; } - std::pair *operator->() const { - return const_cast(Ptr); + pointer operator->() const { + return Ptr; } - bool operator==(const DenseMapIterator &RHS) const { - return Ptr == RHS.Ptr; + bool operator==(const ConstIterator &RHS) const { + return Ptr == RHS.operator->(); } - bool operator!=(const DenseMapIterator &RHS) const { - return Ptr != RHS.Ptr; + bool operator!=(const ConstIterator &RHS) const { + return Ptr != RHS.operator->(); } inline DenseMapIterator& operator++() { // Preincrement @@ -475,22 +488,6 @@ } }; -template -class DenseMapConstIterator : public DenseMapIterator { -public: - DenseMapConstIterator() : DenseMapIterator() {} - DenseMapConstIterator(const std::pair *Pos, - const std::pair *E) - : DenseMapIterator(Pos, E) { - } - const std::pair &operator*() const { - return *this->Ptr; - } - const std::pair *operator->() const { - return this->Ptr; - } -}; - } // end namespace llvm #endif Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original) +++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Mon Nov 9 19:02:17 2009 @@ -153,7 +153,7 @@ /// value. If an value is not in the map, it is returned as untracked, /// unlike the getOrInitValueState method. LatticeVal getLatticeState(Value *V) const { - DenseMap::iterator I = ValueState.find(V); + DenseMap::const_iterator I = ValueState.find(V); return I != ValueState.end() ? I->second : LatticeFunc->getUntrackedVal(); } Modified: llvm/trunk/include/llvm/Support/type_traits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/type_traits.h (original) +++ llvm/trunk/include/llvm/Support/type_traits.h Mon Nov 9 19:02:17 2009 @@ -96,6 +96,12 @@ template struct remove_pointer { typedef T type; }; +template +struct conditional { typedef T type; }; + +template +struct conditional { typedef F type; }; + } #endif Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/Andersens.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Mon Nov 9 19:02:17 2009 @@ -518,7 +518,7 @@ /// getObject - Return the node corresponding to the memory object for the /// specified global or allocation instruction. unsigned getObject(Value *V) const { - DenseMap::iterator I = ObjectNodes.find(V); + DenseMap::const_iterator I = ObjectNodes.find(V); assert(I != ObjectNodes.end() && "Value does not have an object in the points-to graph!"); return I->second; @@ -527,7 +527,7 @@ /// getReturnNode - Return the node representing the return value for the /// specified function. unsigned getReturnNode(Function *F) const { - DenseMap::iterator I = ReturnNodes.find(F); + DenseMap::const_iterator I = ReturnNodes.find(F); assert(I != ReturnNodes.end() && "Function does not return a value!"); return I->second; } @@ -535,7 +535,7 @@ /// getVarargNode - Return the node representing the variable arguments /// formal for the specified function. unsigned getVarargNode(Function *F) const { - DenseMap::iterator I = VarargNodes.find(F); + DenseMap::const_iterator I = VarargNodes.find(F); assert(I != VarargNodes.end() && "Function does not take var args!"); return I->second; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Nov 9 19:02:17 2009 @@ -497,7 +497,7 @@ SawPotentiallyThrowing = false; // Beginning of a new try-range? - RangeMapType::iterator L = PadMap.find(BeginLabel); + RangeMapType::const_iterator L = PadMap.find(BeginLabel); if (L == PadMap.end()) // Nope, it was just some random label. continue; Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Mon Nov 9 19:02:17 2009 @@ -366,10 +366,10 @@ if (!DefMBB) return false; - DenseMap::iterator I = IntervalSSMap.find(Reg); + DenseMap::const_iterator I = IntervalSSMap.find(Reg); if (I == IntervalSSMap.end()) return false; - DenseMap::iterator + DenseMap::const_iterator II = Def2SpillMap.find(DefIndex); if (II == Def2SpillMap.end()) return false; Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Mon Nov 9 19:02:17 2009 @@ -201,7 +201,7 @@ } } - for (MBB2IdxMap::iterator itr = mbb2IdxMap.begin(); + for (MBB2IdxMap::const_iterator itr = mbb2IdxMap.begin(); itr != mbb2IdxMap.end(); ++itr) { errs() << "MBB " << itr->first->getNumber() << " (" << itr->first << ") - [" << itr->second.first << ", " << itr->second.second << "]\n"; Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Mon Nov 9 19:02:17 2009 @@ -364,7 +364,7 @@ /// TokenFactor by PreprocessForRMW. Query the map Store => Load1 (created /// during preprocessing) to determine whether it's legal to introduce such /// "cycle" for a moment. - DenseMap::iterator I = RMWStores.find(Root); + DenseMap::const_iterator I = RMWStores.find(Root); if (I != RMWStores.end() && I->second == N) return true; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Nov 9 19:02:17 2009 @@ -2170,7 +2170,7 @@ // If table selected... if (OpcodeTablePtr) { // Find the Opcode to fuse - DenseMap >::iterator I = + DenseMap >::const_iterator I = OpcodeTablePtr->find((unsigned*)MI->getOpcode()); if (I != OpcodeTablePtr->end()) { unsigned Opcode = I->second.first; @@ -2402,7 +2402,7 @@ if (OpcodeTablePtr) { // Find the Opcode to fuse - DenseMap >::iterator I = + DenseMap >::const_iterator I = OpcodeTablePtr->find((unsigned*)Opc); if (I != OpcodeTablePtr->end()) return true; @@ -2413,7 +2413,7 @@ bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI, unsigned Reg, bool UnfoldLoad, bool UnfoldStore, SmallVectorImpl &NewMIs) const { - DenseMap >::iterator I = + DenseMap >::const_iterator I = MemOp2RegOpTable.find((unsigned*)MI->getOpcode()); if (I == MemOp2RegOpTable.end()) return false; @@ -2530,7 +2530,7 @@ if (!N->isMachineOpcode()) return false; - DenseMap >::iterator I = + DenseMap >::const_iterator I = MemOp2RegOpTable.find((unsigned*)N->getMachineOpcode()); if (I == MemOp2RegOpTable.end()) return false; @@ -2623,7 +2623,7 @@ unsigned X86InstrInfo::getOpcodeAfterMemoryUnfold(unsigned Opc, bool UnfoldLoad, bool UnfoldStore, unsigned *LoadRegIndex) const { - DenseMap >::iterator I = + DenseMap >::const_iterator I = MemOp2RegOpTable.find((unsigned*)Opc); if (I == MemOp2RegOpTable.end()) return 0; Modified: llvm/trunk/lib/Transforms/Scalar/ABCD.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ABCD.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ABCD.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ABCD.cpp Mon Nov 9 19:02:17 2009 @@ -1049,7 +1049,7 @@ /// Prints the body of the dot file void ABCD::InequalityGraph::printBody(raw_ostream &OS) const { - DenseMap >::iterator begin = + DenseMap >::const_iterator begin = graph.begin(), end = graph.end(); for (; begin != end ; ++begin) { Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Nov 9 19:02:17 2009 @@ -624,7 +624,7 @@ /// lookup - Returns the value number of the specified value. Fails if /// the value has not yet been numbered. uint32_t ValueTable::lookup(Value *V) const { - DenseMap::iterator VI = valueNumbering.find(V); + DenseMap::const_iterator VI = valueNumbering.find(V); assert(VI != valueNumbering.end() && "Value not numbered?"); return VI->second; } @@ -644,7 +644,7 @@ /// verifyRemoved - Verify that the value is removed from all internal data /// structures. void ValueTable::verifyRemoved(const Value *V) const { - for (DenseMap::iterator + for (DenseMap::const_iterator I = valueNumbering.begin(), E = valueNumbering.end(); I != E; ++I) { assert(I->first != V && "Inst still occurs in value numbering map!"); } @@ -2011,12 +2011,12 @@ // Walk through the value number scope to make sure the instruction isn't // ferreted away in it. - for (DenseMap::iterator + for (DenseMap::const_iterator I = localAvail.begin(), E = localAvail.end(); I != E; ++I) { const ValueNumberScope *VNS = I->second; while (VNS) { - for (DenseMap::iterator + for (DenseMap::const_iterator II = VNS->table.begin(), IE = VNS->table.end(); II != IE; ++II) { assert(II->second != Inst && "Inst still in value numbering scope!"); } Modified: llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp Mon Nov 9 19:02:17 2009 @@ -507,7 +507,7 @@ /// verifyRemoved - Verify that the value is removed from all internal data /// structures. void ValueTable::verifyRemoved(const Value *V) const { - for (DenseMap::iterator + for (DenseMap::const_iterator I = valueNumbering.begin(), E = valueNumbering.end(); I != E; ++I) { assert(I->first != V && "Inst still occurs in value numbering map!"); } Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Mon Nov 9 19:02:17 2009 @@ -341,11 +341,11 @@ /// getMDs - Get the metadata attached to an Instruction. void MetadataContextImpl:: getMDs(const Instruction *Inst, SmallVectorImpl &MDs) const { - MDStoreTy::iterator I = MetadataStore.find(Inst); + MDStoreTy::const_iterator I = MetadataStore.find(Inst); if (I == MetadataStore.end()) return; MDs.resize(I->second.size()); - for (MDMapTy::iterator MI = I->second.begin(), ME = I->second.end(); + for (MDMapTy::const_iterator MI = I->second.begin(), ME = I->second.end(); MI != ME; ++MI) // MD kinds are numbered from 1. MDs[MI->first - 1] = std::make_pair(MI->first, MI->second); Modified: llvm/trunk/unittests/ADT/DenseMapTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseMapTest.cpp?rev=86636&r1=86635&r2=86636&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/DenseMapTest.cpp (original) +++ llvm/trunk/unittests/ADT/DenseMapTest.cpp Mon Nov 9 19:02:17 2009 @@ -164,4 +164,16 @@ } } +// const_iterator test +TEST_F(DenseMapTest, ConstIteratorTest) { + // Check conversion from iterator to const_iterator. + DenseMap::iterator it = uintMap.begin(); + DenseMap::const_iterator cit(it); + EXPECT_TRUE(it == cit); + + // Check copying of const_iterators. + DenseMap::const_iterator cit2(cit); + EXPECT_TRUE(cit == cit2); +} + } From clattner at apple.com Mon Nov 9 19:04:53 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Nov 2009 17:04:53 -0800 Subject: [llvm-commits] [llvm] r86628 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/X86/X86Subtarget.h In-Reply-To: <80411469-B27A-4B78-968B-D60C7DB43BDF@apple.com> References: <200911100015.nAA0FmdV007190@zion.cs.uiuc.edu> <80411469-B27A-4B78-968B-D60C7DB43BDF@apple.com> Message-ID: <43FA9A68-ADC7-405A-B405-C2BA7F75600F@apple.com> On Nov 9, 2009, at 4:52 PM, David Goodwin wrote: > r86634 Thanks David! From sabre at nondot.org Mon Nov 9 19:08:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 01:08:51 -0000 Subject: [llvm-commits] [llvm] r86637 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911100108.nAA18pl1009326@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 19:08:51 2009 New Revision: 86637 URL: http://llvm.org/viewvc/llvm-project?rev=86637&view=rev Log: add a new SimplifyInstruction API, which is like ConstantFoldInstruction, except that the result may not be a constant. Switch jump threading to use it so that it gets things like (X & 0) -> 0, which occur when phi preds are deleted and the remaining phi pred was a zero. Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86637&r1=86636&r2=86637&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original) +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Mon Nov 9 19:08:51 2009 @@ -17,10 +17,10 @@ #define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H namespace llvm { + class Instruction; class Value; class TargetData; - /// SimplifyAndInst - Given operands for an And, see if we can /// fold the result. If not, this returns null. Value *SimplifyAndInst(Value *LHS, Value *RHS, @@ -55,6 +55,10 @@ Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const TargetData *TD = 0); + /// SimplifyInstruction - See if we can compute a simplified version of this + /// instruction. If not, this returns null. + Value *SimplifyInstruction(Instruction *I, const TargetData *TD = 0); + } // end namespace llvm #endif Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86637&r1=86636&r2=86637&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 19:08:51 2009 @@ -291,3 +291,23 @@ return SimplifyFCmpInst(Predicate, LHS, RHS, TD); } + +/// SimplifyInstruction - See if we can compute a simplified version of this +/// instruction. If not, this returns null. +Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD) { + switch (I->getOpcode()) { + default: + return ConstantFoldInstruction(I, TD); + case Instruction::And: + return SimplifyAndInst(I->getOperand(0), I->getOperand(1), TD); + case Instruction::Or: + return SimplifyOrInst(I->getOperand(0), I->getOperand(1), TD); + case Instruction::ICmp: + return SimplifyICmpInst(cast(I)->getPredicate(), + I->getOperand(0), I->getOperand(1), TD); + case Instruction::FCmp: + return SimplifyFCmpInst(cast(I)->getPredicate(), + I->getOperand(0), I->getOperand(1), TD); + } +} + Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86637&r1=86636&r2=86637&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 19:08:51 2009 @@ -16,7 +16,6 @@ #include "llvm/IntrinsicInst.h" #include "llvm/LLVMContext.h" #include "llvm/Pass.h" -#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" @@ -223,9 +222,9 @@ Instruction *User = cast(U.getUser()); U = PNV; - // See if we can simplify it (constant folding). - if (Constant *C = ConstantFoldInstruction(User, TD)) { - User->replaceAllUsesWith(C); + // See if we can simplify it. + if (Value *V = SimplifyInstruction(User, TD)) { + User->replaceAllUsesWith(V); User->eraseFromParent(); } } @@ -1203,8 +1202,8 @@ BI = NewBB->begin(); for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Constant *C = ConstantFoldInstruction(Inst, TD)) { - Inst->replaceAllUsesWith(C); + if (Value *V = SimplifyInstruction(Inst, TD)) { + Inst->replaceAllUsesWith(V); Inst->eraseFromParent(); continue; } From sabre at nondot.org Mon Nov 9 19:19:06 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 01:19:06 -0000 Subject: [llvm-commits] [llvm] r86639 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911100119.nAA1J6Ru009661@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 19:19:06 2009 New Revision: 86639 URL: http://llvm.org/viewvc/llvm-project?rev=86639&view=rev Log: don't invalidate PN, rewrite of this code is in progress anyway. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86639&r1=86638&r2=86639&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 19:19:06 2009 @@ -223,10 +223,11 @@ U = PNV; // See if we can simplify it. - if (Value *V = SimplifyInstruction(User, TD)) { - User->replaceAllUsesWith(V); - User->eraseFromParent(); - } + if (User != PN) + if (Value *V = SimplifyInstruction(User, TD)) { + User->replaceAllUsesWith(V); + User->eraseFromParent(); + } } PN->replaceAllUsesWith(PNV); From gohman at apple.com Mon Nov 9 19:33:08 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Nov 2009 01:33:08 -0000 Subject: [llvm-commits] [llvm] r86640 - /llvm/trunk/test/Transforms/LCSSA/indirectbr.ll Message-ID: <200911100133.nAA1X90K010143@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 19:33:08 2009 New Revision: 86640 URL: http://llvm.org/viewvc/llvm-project?rev=86640&view=rev Log: Trim a bunch of unneeded code from this testcase. Modified: llvm/trunk/test/Transforms/LCSSA/indirectbr.ll Modified: llvm/trunk/test/Transforms/LCSSA/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LCSSA/indirectbr.ll?rev=86640&r1=86639&r2=86640&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LCSSA/indirectbr.ll (original) +++ llvm/trunk/test/Transforms/LCSSA/indirectbr.ll Mon Nov 9 19:33:08 2009 @@ -35,7 +35,7 @@ "23": ; preds = %"1375", %"22" %0 = phi i32 [ undef, %"22" ], [ %1, %"1375" ] ; [#uses=1] - indirectbr i8* undef, [label %"15", label %"24", label %"25", label %"26", label %"27", label %"28", label %"29", label %"30", label %"32", label %"32", label %"33", label %"35", label %"36", label %"41", label %"41", label %"60", label %"61", label %"65", label %"76", label %"87", label %"95", label %"103", label %"104", label %"108", label %"119", label %"130", label %"138", label %"146", label %"164", label %"162", label %"163", label %"166", label %"167", label %"173", label %"173", label %"173", label %"173", label %"173", label %"192", label %"193", label %"194", label %"196", label %"206", label %"231", label %"241", label %"251", label %"261", label %"307", label %"353", label %"354", label %"355", label %"361", label %"367", label %"400", label %"433", label %"466", label %"499", label %"509", label %"519", label %"529", label %"571", label %"589", label %"607", label %"635", label %"655", label %"664", label %"671", label %"680", label %"687", label %"692", labe! l %"698", label %"704", label %"715", label %"715", label %"716", label %"725", label %"725", label %"725", label %"725", label %"724", label %"724", label %"724", label %"724", label %"737", label %"737", label %"737", label %"737", label %"761", label %"758", label %"759", label %"760", label %"766", label %"763", label %"764", label %"765", label %"771", label %"768", label %"769", label %"770", label %"780", label %"777", label %"778", label %"779", label %"821", label %"826", label %"831", label %"832", label %"833", label %"836", label %"836", label %"886", label %"905", label %"978", label %"978", label %"1136", label %"1166", label %"1179", label %"1201", label %"1212", label %"1212", label %"1274", label %"1284", label %"1284", label %"1346", label %"1347", label %"1348", label %"1349", label %"1350", label %"1353", label %"1353", label %"1353", label %"1355", label %"1355", label %"1357", label %"1357", label %"1358", label %"1359", label %"1374", label %"1375", l! abel %"1376", label %"1377", label %"1378", label %"1379", lab! el %"138 6", label %"1395", label %"1394", label %"1425", label %"1426", label %"1440", label %"1449", label %"1455", label %"1461", label %"1471", label %"1482", label %"1484", label %"1486", label %"1489", label %"1489", label %"1492", label %"1494", label %"1494", label %"1497", label %"1499", label %"1499", label %"1515", label %"1546", label %"1546", label %"1566", label %"1584", label %"1587", label %"1591", label %"1605", label %"1609", label %"1609", label %"1640", label %"1648", label %"1651", label %"1703", label %"1710", label %"1718", label %"1724", label %"1725", label %"1726", label %"1727", label %"1728", label %"1731", label %"1732", label %"1733", label %"1734", label %"1735", label %"1741", label %"1750", label %"1752", label %"1754", label %"1755", label %"1757", label %"1759", label %"1761", label %"1764", label %"1764", label %"1766", label %"1768", label %"1775", label %"1775", label %"1781", label %"1781", label %"1790", label %"1791", label %"1801", label %"18! 02", label %"1803", label %"1805", label %"1807", label %"1809", label %"1817", label %"1819", label %"1821", label %"1823", label %"1825", label %"1827", label %"1836", label %"1836", label %"1845", label %"1845", label %"1848", label %"1849", label %"1851", label %"1853", label %"1856", label %"1861", label %"1861"] + indirectbr i8* undef, [label %"15", label %"24", label %"25", label %"26", label %"27", label %"28", label %"29", label %"30", label %"32", label %"32", label %"33", label %"167", label %"173", label %"173", label %"173", label %"173", label %"173", label %"192", label %"193", label %"194", label %"196", label %"206", label %"231", label %"241", label %"251", label %"261", label %"307", label %"353", label %"354", label %"355", label %"361", label %"367", label %"400", label %"433", label %"466", label %"499", label %"509", label %"519", label %"529", label %"571", label %"589", label %"607", label %"635", label %"655", label %"664", label %"671", label %"680", label %"687", label %"692", label %"698", label %"704", label %"715", label %"715", label %"716", label %"725", label %"725", label %"725", label %"725", label %"724", label %"724", label %"724", label %"724", label %"737", label %"737", label %"737", label %"737", label %"761", label %"758", label %"759", label %"! 760", label %"766", label %"763", label %"764", label %"765", label %"771", label %"768", label %"769", label %"770", label %"780", label %"777", label %"778", label %"779", label %"821", label %"826", label %"831", label %"832", label %"833", label %"836", label %"836", label %"886", label %"905", label %"978", label %"978", label %"1136", label %"1166", label %"1179", label %"1201", label %"1212", label %"1212", label %"1274", label %"1284", label %"1284", label %"1346", label %"1347", label %"1348", label %"1349", label %"1350", label %"1353", label %"1353", label %"1353", label %"1355", label %"1355", label %"1357", label %"1357", label %"1358", label %"1359", label %"1374", label %"1375", label %"1376", label %"1377", label %"1378", label %"1379", label %"1386", label %"1395", label %"1394", label %"1425", label %"1426", label %"1440", label %"1449", label %"1455", label %"1461", label %"1471", label %"1482", label %"1484", label %"1486", label %"1489", label %"1489", ! label %"1492", label %"1494", label %"1494", label %"1497", la! bel %"14 99", label %"1499", label %"1515", label %"1546", label %"1546", label %"1566", label %"1584", label %"1587", label %"1591", label %"1605", label %"1609", label %"1609", label %"1640", label %"1648", label %"1651", label %"1703", label %"1710", label %"1718", label %"1724", label %"1725", label %"1726", label %"1727", label %"1728", label %"1731", label %"1732", label %"1733", label %"1734", label %"1735", label %"1741", label %"1750", label %"1752", label %"1754", label %"1755", label %"1757", label %"1759", label %"1761", label %"1764", label %"1764", label %"1766", label %"1768", label %"1775", label %"1775", label %"1781", label %"1781", label %"1790", label %"1827", label %"1836", label %"1836", label %"1845", label %"1845", label %"1848", label %"1849", label %"1851", label %"1853", label %"1856", label %"1861", label %"1861"] "24": ; preds = %"23" unreachable @@ -64,63 +64,6 @@ "33": ; preds = %"23" unreachable -"35": ; preds = %"23" - unreachable - -"36": ; preds = %"23" - unreachable - -"60": ; preds = %"23" - unreachable - -"61": ; preds = %"23" - unreachable - -"65": ; preds = %"23" - unreachable - -"76": ; preds = %"23" - unreachable - -"87": ; preds = %"23" - unreachable - -"95": ; preds = %"23" - unreachable - -"103": ; preds = %"23" - unreachable - -"104": ; preds = %"23" - unreachable - -"108": ; preds = %"23" - unreachable - -"119": ; preds = %"23" - unreachable - -"130": ; preds = %"23" - unreachable - -"138": ; preds = %"23" - unreachable - -"146": ; preds = %"23" - unreachable - -"162": ; preds = %"23" - unreachable - -"163": ; preds = %"23" - unreachable - -"164": ; preds = %"23" - unreachable - -"166": ; preds = %"23" - unreachable - "167": ; preds = %"23" unreachable @@ -564,42 +507,6 @@ "1790": ; preds = %"23" unreachable -"1791": ; preds = %"23" - unreachable - -"1801": ; preds = %"23" - unreachable - -"1802": ; preds = %"23" - unreachable - -"1803": ; preds = %"23" - unreachable - -"1805": ; preds = %"23" - unreachable - -"1807": ; preds = %"23" - unreachable - -"1809": ; preds = %"23" - unreachable - -"1817": ; preds = %"23" - unreachable - -"1819": ; preds = %"23" - unreachable - -"1821": ; preds = %"23" - unreachable - -"1823": ; preds = %"23" - unreachable - -"1825": ; preds = %"23" - unreachable - "1827": ; preds = %"23" unreachable From gohman at apple.com Mon Nov 9 19:36:20 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Nov 2009 01:36:20 -0000 Subject: [llvm-commits] [llvm] r86641 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911100136.nAA1aK57010254@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 19:36:20 2009 New Revision: 86641 URL: http://llvm.org/viewvc/llvm-project?rev=86641&view=rev Log: Minor code simplification. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86641&r1=86640&r2=86641&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Mon Nov 9 19:36:20 2009 @@ -600,7 +600,7 @@ // Walk through equivalence sets looking for actual exact matches. while (MergePotentials.size() > 1) { - unsigned CurHash = prior(MergePotentials.end())->first; + unsigned CurHash = MergePotentials.back().first; // Build SameTails, identifying the set of blocks with this hash code // and with the maximum number of instructions in common. From gohman at apple.com Mon Nov 9 19:37:58 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Nov 2009 01:37:58 -0000 Subject: [llvm-commits] [llvm] r86642 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911100137.nAA1bwXc010311@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 9 19:37:57 2009 New Revision: 86642 URL: http://llvm.org/viewvc/llvm-project?rev=86642&view=rev Log: Remove an unused variable. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86642&r1=86641&r2=86642&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Mon Nov 9 19:37:57 2009 @@ -1179,7 +1179,6 @@ // Analyze the branch at the end of the block before the succ. MachineBasicBlock *SuccBB = *SI; MachineFunction::iterator SuccPrev = SuccBB; --SuccPrev; - std::vector SuccPrevCond; // If this block doesn't already fall-through to that successor, and if // the succ doesn't already have a block that can fall through into it, From ofv at wanadoo.es Mon Nov 9 19:45:05 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 10 Nov 2009 01:45:05 -0000 Subject: [llvm-commits] [llvm] r86644 - /llvm/trunk/cmake/config-ix.cmake Message-ID: <200911100145.nAA1j5O6010608@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 9 19:45:05 2009 New Revision: 86644 URL: http://llvm.org/viewvc/llvm-project?rev=86644&view=rev Log: CMake: Remove unnecessary `unset' which was not supported by old cmake releases. Modified: llvm/trunk/cmake/config-ix.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86644&r1=86643&r2=86644&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Mon Nov 9 19:45:05 2009 @@ -136,7 +136,6 @@ mark_as_advanced(HAVE_${NAME}) else(LLVM_PATH_${NAME}) set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?") - unset(LLVM_PATH_${NAME} CACHE) endif(LLVM_PATH_${NAME}) endfunction() From johnny.chen at apple.com Mon Nov 9 19:46:22 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 9 Nov 2009 17:46:22 -0800 Subject: [llvm-commits] Question on emitLoadStoreInstruction() of ARMCodeEmitter.cpp Message-ID: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> Hi, I have a question wrt the following fragment of code: // Operand 0 of a pre- and post-indexed store is the address base // writeback. Skip it. bool Skipped = false; if (IsPrePost && Form == ARMII::StFrm) { ++OpIdx; Skipped = true; } // Set first operand if (ImplicitRd) // Special handling for implicit use (e.g. PC). Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd) << ARMII::RegRdShift); else Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; and from the Record definition of LDRB_POST: def LDRB_POST { // Instruction InstARM I AI2ldbpo field bits<32> Inst = { ?, ?, ?, ?, 0, 1, ?, 0, ?, 1, 0, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? }; string Namespace = "ARM"; dag OutOperandList = (outs GPR:$dst, GPR:$base_wb); dag InOperandList = (ins GPR:$base, am2offset:$offset, pred:$p); string AsmString = "ldrb${p} $dst, [$base], $offset"; it looks like the processing of "address base writeback" should happen after the processing of RegRd, if the ordering of OutOperandList followed by InOperandList is to be observed. Is my understanding of the ordering of the MachineOperands correct? If this is the case, then there could be some bug in the codegen which compensates for the incorrect ordering/processing of base_writeback/dst? Thanks. From ofv at wanadoo.es Mon Nov 9 19:47:24 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 10 Nov 2009 02:47:24 +0100 Subject: [llvm-commits] [llvm] r86547 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake In-Reply-To: <05076F8D-8E99-4BCD-BDA0-AB1F2FD5DA05@apple.com> (Mike Stump's message of "Mon, 9 Nov 2009 15:48:01 -0800") References: <200911091526.nA9FQhRr016776@zion.cs.uiuc.edu> <05076F8D-8E99-4BCD-BDA0-AB1F2FD5DA05@apple.com> Message-ID: <87r5s76thv.fsf@telefonica.net> Mike Stump writes: > I get: > > -- Performing Test HAVE_U_INT64_T - Success > CMake Error at cmake/config-ix.cmake:139 (unset): > Unknown CMake command "unset". > Call Stack (most recent call first): > cmake/config-ix.cmake:143 (llvm_find_program) > CMakeLists.txt:161 (include) > > > -- Configuring incomplete, errors occurred! > > ? I'm using cmake version 2.6-patch 2. Thanks. unset was introduced by -patch4, IIRC. As it seems that it is not strictly required, I removed it. -- ?scar From sabre at nondot.org Mon Nov 9 19:56:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 01:56:04 -0000 Subject: [llvm-commits] [llvm] r86645 - /llvm/trunk/lib/Analysis/InstructionSimplify.cpp Message-ID: <200911100156.nAA1u4Rd011110@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 19:56:04 2009 New Revision: 86645 URL: http://llvm.org/viewvc/llvm-project?rev=86645&view=rev Log: remove some redundant parens. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86645&r1=86644&r2=86645&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 19:56:04 2009 @@ -63,8 +63,8 @@ // A & ~A = ~A & A = 0 Value *A, *B; - if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || - (match(Op1, m_Not(m_Value(A))) && A == Op0)) + if (match(Op0, m_Not(m_Value(A)) && A == Op1) || + match(Op1, m_Not(m_Value(A)) && A == Op0)) return Constant::getNullValue(Op0->getType()); // (A | ?) & A = A @@ -123,8 +123,8 @@ // A | ~A = ~A | A = -1 Value *A, *B; - if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || - (match(Op1, m_Not(m_Value(A))) && A == Op0)) + if (match(Op0, m_Not(m_Value(A)) && A == Op1) || + match(Op1, m_Not(m_Value(A)) && A == Op0)) return Constant::getAllOnesValue(Op0->getType()); // (A & ?) | A = A From sabre at nondot.org Mon Nov 9 19:57:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 01:57:32 -0000 Subject: [llvm-commits] [llvm] r86646 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911100157.nAA1vWM3011198@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 19:57:31 2009 New Revision: 86646 URL: http://llvm.org/viewvc/llvm-project?rev=86646&view=rev Log: make jump threading recursively simplify expressions instead of doing it just one level deep. On the testcase we go from getting this: F1: ; preds = %T2 %F = and i1 true, %cond ; [#uses=1] br i1 %F, label %X, label %Y to a fully threaded: F1: ; preds = %T2 br label %Y This changes gets us to the point where we're forming (too many) switch instructions on doug's strswitch testcase. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86646&r1=86645&r2=86646&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Nov 9 19:57:31 2009 @@ -182,6 +182,40 @@ //===----------------------------------------------------------------------===// +/// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then +/// delete the From instruction. In addition to a basic RAUW, this does a +/// recursive simplification of the newly formed instructions. This catches +/// things where one simplification exposes other opportunities. This only +/// simplifies and deletes scalar operations, it does not change the CFG. +/// +static void ReplaceAndSimplifyAllUses(Instruction *From, Value *To, + const TargetData *TD) { + assert(From != To && "ReplaceAndSimplifyAllUses(X,X) is not valid!"); + + // FromHandle - This keeps a weakvh on the from value so that we can know if + // it gets deleted out from under us in a recursive simplification. + WeakVH FromHandle(From); + + while (!From->use_empty()) { + // Update the instruction to use the new value. + Use &U = From->use_begin().getUse(); + Instruction *User = cast(U.getUser()); + U = To; + + // See if we can simplify it. + if (Value *V = SimplifyInstruction(User, TD)) { + // Recursively simplify this. + ReplaceAndSimplifyAllUses(User, V, TD); + + // If the recursive simplification ended up revisiting and deleting 'From' + // then we're done. + if (FromHandle == 0) + return; + } + } + From->eraseFromParent(); +} + /// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this /// method is called when we're about to delete Pred as a predecessor of BB. If @@ -212,26 +246,11 @@ Value *PNV = PN->hasConstantValue(); if (PNV == 0) continue; + // If we're able to simplify the phi to a single value, substitute the new + // value into all of its uses. assert(PNV != PN && "hasConstantValue broken"); - // If we're able to simplify the phi to a constant, simplify it into its - // uses. - while (!PN->use_empty()) { - // Update the instruction to use the new value. - Use &U = PN->use_begin().getUse(); - Instruction *User = cast(U.getUser()); - U = PNV; - - // See if we can simplify it. - if (User != PN) - if (Value *V = SimplifyInstruction(User, TD)) { - User->replaceAllUsesWith(V); - User->eraseFromParent(); - } - } - - PN->replaceAllUsesWith(PNV); - PN->eraseFromParent(); + ReplaceAndSimplifyAllUses(PN, PNV, TD); // If recursive simplification ended up deleting the next PHI node we would // iterate to, then our iterator is invalid, restart scanning from the top @@ -1203,9 +1222,12 @@ BI = NewBB->begin(); for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { Instruction *Inst = BI++; + if (Value *V = SimplifyInstruction(Inst, TD)) { - Inst->replaceAllUsesWith(V); - Inst->eraseFromParent(); + WeakVH BIHandle(BI); + ReplaceAndSimplifyAllUses(Inst, V, TD); + if (BIHandle == 0) + BI = NewBB->begin(); continue; } Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86646&r1=86645&r2=86646&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Mon Nov 9 19:57:31 2009 @@ -203,3 +203,35 @@ ; CHECK-NEXT: phi i32 } + +declare i1 @test8a() + +define i32 @test8b(i1 %cond, i1 %cond2) { +; CHECK: @test8b +T0: + %A = call i1 @test8a() + br i1 %A, label %T1, label %F1 +T1: + %B = call i1 @test8a() + br i1 %B, label %T2, label %F1 +T2: + %C = call i1 @test8a() + br i1 %cond, label %T3, label %F1 +T3: + ret i32 0 + +F1: +; TODO: F1 uncond branch block should be removed, T2 should jump directly to Y. +; CHECK: F1: +; CHECK-NEXT br label %Y + %D = phi i32 [0, %T0], [0, %T1], [1, %T2] + %E = icmp eq i32 %D, 1 + %F = and i1 %E, %cond + br i1 %F, label %X, label %Y +X: + call i1 @test8a() + ret i32 1 +Y: + ret i32 2 +} + From sabre at nondot.org Mon Nov 9 20:04:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 02:04:54 -0000 Subject: [llvm-commits] [llvm] r86648 - /llvm/trunk/lib/Analysis/InstructionSimplify.cpp Message-ID: <200911100204.nAA24svG011529@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 20:04:54 2009 New Revision: 86648 URL: http://llvm.org/viewvc/llvm-project?rev=86648&view=rev Log: I misread the parens, not so redundant after all. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86648&r1=86647&r2=86648&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 9 20:04:54 2009 @@ -63,8 +63,8 @@ // A & ~A = ~A & A = 0 Value *A, *B; - if (match(Op0, m_Not(m_Value(A)) && A == Op1) || - match(Op1, m_Not(m_Value(A)) && A == Op0)) + if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || + (match(Op1, m_Not(m_Value(A))) && A == Op0)) return Constant::getNullValue(Op0->getType()); // (A | ?) & A = A @@ -123,8 +123,8 @@ // A | ~A = ~A | A = -1 Value *A, *B; - if (match(Op0, m_Not(m_Value(A)) && A == Op1) || - match(Op1, m_Not(m_Value(A)) && A == Op0)) + if ((match(Op0, m_Not(m_Value(A))) && A == Op1) || + (match(Op1, m_Not(m_Value(A))) && A == Op0)) return Constant::getAllOnesValue(Op0->getType()); // (A & ?) | A = A From bruno.cardoso at gmail.com Mon Nov 9 20:35:14 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Nov 2009 02:35:14 -0000 Subject: [llvm-commits] [llvm] r86651 - /llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Message-ID: <200911100235.nAA2ZERO012563@zion.cs.uiuc.edu> Author: bruno Date: Mon Nov 9 20:35:13 2009 New Revision: 86651 URL: http://llvm.org/viewvc/llvm-project?rev=86651&view=rev Log: Fix PR5445 Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=86651&r1=86650&r2=86651&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Mon Nov 9 20:35:13 2009 @@ -281,7 +281,7 @@ // Floating Point Patterns //===----------------------------------------------------------------------===// def fpimm0 : PatLeaf<(fpimm), [{ - return N->isExactlyValue(+0.0); + return N->isExactlyValue(+0.0) || N->isExactlyValue(-0.0); }]>; def : Pat<(f32 fpimm0), (MTC1 ZERO)>; From daniel at zuster.org Mon Nov 9 20:40:21 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 02:40:21 -0000 Subject: [llvm-commits] [llvm] r86653 - /llvm/trunk/utils/lit/lit.py Message-ID: <200911100240.nAA2eLS5012769@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 20:40:21 2009 New Revision: 86653 URL: http://llvm.org/viewvc/llvm-project?rev=86653&view=rev Log: lit: Fix bug in --show-suites which accidentally override the list of tests. Modified: llvm/trunk/utils/lit/lit.py Modified: llvm/trunk/utils/lit/lit.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit.py?rev=86653&r1=86652&r2=86653&view=diff ============================================================================== --- llvm/trunk/utils/lit/lit.py (original) +++ llvm/trunk/utils/lit/lit.py Mon Nov 9 20:40:21 2009 @@ -452,8 +452,8 @@ print '-- Test Suites --' suitesAndTests = suitesAndTests.items() suitesAndTests.sort(key = lambda (ts,_): ts.name) - for ts,tests in suitesAndTests: - print ' %s - %d tests' %(ts.name, len(tests)) + for ts,ts_tests in suitesAndTests: + print ' %s - %d tests' %(ts.name, len(ts_tests)) print ' Source Root: %s' % ts.source_root print ' Exec Root : %s' % ts.exec_root From daniel at zuster.org Mon Nov 9 20:41:18 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 02:41:18 -0000 Subject: [llvm-commits] [llvm] r86654 - in /llvm/trunk/utils/lit: ExampleTests.ObjDir/ ExampleTests/ ExampleTests/Clang/ ExampleTests/LLVM.InTree/ ExampleTests/LLVM.InTree/test/ ExampleTests/LLVM.InTree/test/Bar/ ExampleTests/LLVM.OutOfTree/ ExampleTests/LLVM.OutOfTree/obj/ ExampleTests/LLVM.OutOfTree/obj/test/ ExampleTests/LLVM.OutOfTree/obj/test/Foo/ ExampleTests/LLVM.OutOfTree/src/ ExampleTests/LLVM.OutOfTree/src/test/ ExampleTests/LLVM.OutOfTree/src/test/Foo/ ExampleTests/ShExternal/ ExampleTests/ShInternal/ ExampleTests/Tc... Message-ID: <200911100241.nAA2fJLX012863@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 20:41:17 2009 New Revision: 86654 URL: http://llvm.org/viewvc/llvm-project?rev=86654&view=rev Log: lit: Add ExampleTests, for testing lit and demonstrating test suite features. Added: llvm/trunk/utils/lit/ExampleTests/ llvm/trunk/utils/lit/ExampleTests.ObjDir/ llvm/trunk/utils/lit/ExampleTests.ObjDir/lit.site.cfg llvm/trunk/utils/lit/ExampleTests/Clang/ llvm/trunk/utils/lit/ExampleTests/Clang/fsyntax-only.c llvm/trunk/utils/lit/ExampleTests/Clang/lit.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/bar-test.ll llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/dg.exp llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.site.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/site.exp llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/lit.local.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/Foo/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/Foo/lit.local.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/lit.site.cfg llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/site.exp llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/data.txt llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/dg.exp llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/pct-S.ll llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/lit.cfg llvm/trunk/utils/lit/ExampleTests/ShExternal/ llvm/trunk/utils/lit/ExampleTests/ShExternal/lit.local.cfg llvm/trunk/utils/lit/ExampleTests/ShInternal/ llvm/trunk/utils/lit/ExampleTests/ShInternal/lit.local.cfg llvm/trunk/utils/lit/ExampleTests/TclTest/ llvm/trunk/utils/lit/ExampleTests/TclTest/lit.local.cfg llvm/trunk/utils/lit/ExampleTests/TclTest/stderr-pipe.ll llvm/trunk/utils/lit/ExampleTests/TclTest/tcl-redir-1.ll llvm/trunk/utils/lit/ExampleTests/fail.c llvm/trunk/utils/lit/ExampleTests/lit.cfg llvm/trunk/utils/lit/ExampleTests/pass.c llvm/trunk/utils/lit/ExampleTests/xfail.c llvm/trunk/utils/lit/ExampleTests/xpass.c Added: llvm/trunk/utils/lit/ExampleTests.ObjDir/lit.site.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests.ObjDir/lit.site.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests.ObjDir/lit.site.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests.ObjDir/lit.site.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,15 @@ +# -*- Python -*- + +# Site specific configuration file. +# +# Typically this will be generated by the build system to automatically set +# certain configuration variables which cannot be autodetected, so that 'lit' +# can easily be used on the command line. + +import os + +# Preserve the obj_root, for use by the main lit.cfg. +config.example_obj_root = os.path.dirname(__file__) + +lit.load_config(config, os.path.join(config.test_source_root, + 'lit.cfg')) Added: llvm/trunk/utils/lit/ExampleTests/Clang/fsyntax-only.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/Clang/fsyntax-only.c?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/Clang/fsyntax-only.c (added) +++ llvm/trunk/utils/lit/ExampleTests/Clang/fsyntax-only.c Mon Nov 9 20:41:17 2009 @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only -Xclang -verify %s + +int f0(void) {} // expected-warning {{control reaches end of non-void function}} + Added: llvm/trunk/utils/lit/ExampleTests/Clang/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/Clang/lit.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/Clang/lit.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/Clang/lit.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,80 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'Clang' + +# testFormat: The test format to use to interpret tests. +# +# For now we require '&&' between commands, until they get globally killed and +# the test runner updated. +config.test_format = lit.formats.ShTest(execute_external = True) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.c', '.cpp', '.m', '.mm'] + +# target_triple: Used by ShTest and TclTest formats for XFAIL checks. +config.target_triple = 'foo' + +### + +# Discover the 'clang' and 'clangcc' to use. + +import os + +def inferClang(PATH): + # Determine which clang to use. + clang = os.getenv('CLANG') + + # If the user set clang in the environment, definitely use that and don't + # try to validate. + if clang: + return clang + + # Otherwise look in the path. + clang = lit.util.which('clang', PATH) + + if not clang: + lit.fatal("couldn't find 'clang' program, try setting " + "CLANG in your environment") + + return clang + +def inferClangCC(clang, PATH): + clangcc = os.getenv('CLANGCC') + + # If the user set clang in the environment, definitely use that and don't + # try to validate. + if clangcc: + return clangcc + + # Otherwise try adding -cc since we expect to be looking in a build + # directory. + if clang.endswith('.exe'): + clangccName = clang[:-4] + '-cc.exe' + else: + clangccName = clang + '-cc' + clangcc = lit.util.which(clangccName, PATH) + if not clangcc: + # Otherwise ask clang. + res = lit.util.capture([clang, '-print-prog-name=clang-cc']) + res = res.strip() + if res and os.path.exists(res): + clangcc = res + + if not clangcc: + lit.fatal("couldn't find 'clang-cc' program, try setting " + "CLANGCC in your environment") + + return clangcc + +clang = inferClang(config.environment['PATH']) +if not lit.quiet: + lit.note('using clang: %r' % clang) +config.substitutions.append( (' clang ', ' ' + clang + ' ') ) + +clang_cc = inferClangCC(clang, config.environment['PATH']) +if not lit.quiet: + lit.note('using clang-cc: %r' % clang_cc) +config.substitutions.append( (' clang-cc ', ' ' + clang_cc + ' ') ) Added: llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/bar-test.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/bar-test.ll?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/bar-test.ll (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/bar-test.ll Mon Nov 9 20:41:17 2009 @@ -0,0 +1,3 @@ +; RUN: true +; XFAIL: * +; XTARGET: darwin Added: llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/dg.exp?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/dg.exp (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/Bar/dg.exp Mon Nov 9 20:41:17 2009 @@ -0,0 +1,6 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} + Added: llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,151 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +import os + +# name: The name of this test suite. +config.name = 'LLVM' + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.TclTest() + +# suffixes: A list of file extensions to treat as test files, this is actually +# set by on_clone(). +config.suffixes = [] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root path where tests should be run. +llvm_obj_root = getattr(config, 'llvm_obj_root', None) +if llvm_obj_root is not None: + config.test_exec_root = os.path.join(llvm_obj_root, 'test') + +### + +import os + +# Check that the object root is known. +if config.test_exec_root is None: + # Otherwise, we haven't loaded the site specific configuration (the user is + # probably trying to run on a test file directly, and either the site + # configuration hasn't been created by the build system, or we are in an + # out-of-tree build situation). + + # Try to detect the situation where we are using an out-of-tree build by + # looking for 'llvm-config'. + # + # FIXME: I debated (i.e., wrote and threw away) adding logic to + # automagically generate the lit.site.cfg if we are in some kind of fresh + # build situation. This means knowing how to invoke the build system + # though, and I decided it was too much magic. + + llvm_config = lit.util.which('llvm-config', config.environment['PATH']) + if not llvm_config: + lit.fatal('No site specific configuration available!') + + # Get the source and object roots. + llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip() + llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip() + + # Validate that we got a tree which points to here. + this_src_root = os.path.dirname(config.test_source_root) + if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root): + lit.fatal('No site specific configuration available!') + + # Check that the site specific configuration exists. + site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg') + if not os.path.exists(site_cfg): + lit.fatal('No site specific configuration available!') + + # Okay, that worked. Notify the user of the automagic, and reconfigure. + lit.note('using out-of-tree build at %r' % llvm_obj_root) + lit.load_config(config, site_cfg) + raise SystemExit + +### + +# Load site data from DejaGNU's site.exp. +import re +site_exp = {} +# FIXME: Implement lit.site.cfg. +for line in open(os.path.join(config.llvm_obj_root, 'test', 'site.exp')): + m = re.match('set ([^ ]+) "([^"]*)"', line) + if m: + site_exp[m.group(1)] = m.group(2) + +# Add substitutions. +for sub in ['prcontext', 'llvmgcc', 'llvmgxx', 'compile_cxx', 'compile_c', + 'link', 'shlibext', 'ocamlopt', 'llvmdsymutil', 'llvmlibsdir', + 'bugpoint_topts']: + if sub in ('llvmgcc', 'llvmgxx'): + config.substitutions.append(('%' + sub, + site_exp[sub] + ' -emit-llvm -w')) + else: + config.substitutions.append(('%' + sub, site_exp[sub])) + +excludes = [] + +# Provide target_triple for use in XFAIL and XTARGET. +config.target_triple = site_exp['target_triplet'] + +# Provide llvm_supports_target for use in local configs. +targets = set(site_exp["TARGETS_TO_BUILD"].split()) +def llvm_supports_target(name): + return name in targets + +langs = set(site_exp['llvmgcc_langs'].split(',')) +def llvm_gcc_supports(name): + return name in langs + +# Provide on_clone hook for reading 'dg.exp'. +import os +simpleLibData = re.compile(r"""load_lib llvm.exp + +RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]""", + re.MULTILINE) +conditionalLibData = re.compile(r"""load_lib llvm.exp + +if.*\[ ?(llvm[^ ]*) ([^ ]*) ?\].*{ + *RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\] +\}""", re.MULTILINE) +def on_clone(parent, cfg, for_path): + def addSuffixes(match): + if match[0] == '{' and match[-1] == '}': + cfg.suffixes = ['.' + s for s in match[1:-1].split(',')] + else: + cfg.suffixes = ['.' + match] + + libPath = os.path.join(os.path.dirname(for_path), + 'dg.exp') + if not os.path.exists(libPath): + cfg.unsupported = True + return + + # Reset unsupported, in case we inherited it. + cfg.unsupported = False + lib = open(libPath).read().strip() + + # Check for a simple library. + m = simpleLibData.match(lib) + if m: + addSuffixes(m.group(1)) + return + + # Check for a conditional test set. + m = conditionalLibData.match(lib) + if m: + funcname,arg,match = m.groups() + addSuffixes(match) + + func = globals().get(funcname) + if not func: + lit.error('unsupported predicate %r' % funcname) + elif not func(arg): + cfg.unsupported = True + return + # Otherwise, give up. + lit.error('unable to understand %r:\n%s' % (libPath, lib)) + +config.on_clone = on_clone Added: llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.site.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.site.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.site.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/lit.site.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,10 @@ +# -*- Python -*- + +## Autogenerated by Makefile ## +# Do not edit! + +# Preserve some key paths for use by main LLVM test suite config. +config.llvm_obj_root = os.path.dirname(os.path.dirname(__file__)) + +# Let the main config do the real work. +lit.load_config(config, os.path.join(config.llvm_obj_root, 'test/lit.cfg')) Added: llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/site.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/site.exp?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/site.exp (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.InTree/test/site.exp Mon Nov 9 20:41:17 2009 @@ -0,0 +1,30 @@ +## these variables are automatically generated by make ## +# Do not edit here. If you wish to override these values +# edit the last section +set target_triplet "x86_64-apple-darwin10" +set TARGETS_TO_BUILD "X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend MSIL CppBackend" +set llvmgcc_langs "c,c++,objc,obj-c++" +set llvmgcc_version "4.2.1" +set prcontext "/usr/bin/tclsh8.4 /Volumes/Data/ddunbar/llvm/test/Scripts/prcontext.tcl" +set llvmtoolsdir "/Users/ddunbar/llvm.obj.64/Debug/bin" +set llvmlibsdir "/Users/ddunbar/llvm.obj.64/Debug/lib" +set srcroot "/Volumes/Data/ddunbar/llvm" +set objroot "/Volumes/Data/ddunbar/llvm.obj.64" +set srcdir "/Volumes/Data/ddunbar/llvm/test" +set objdir "/Volumes/Data/ddunbar/llvm.obj.64/test" +set gccpath "/usr/bin/gcc -arch x86_64" +set gxxpath "/usr/bin/g++ -arch x86_64" +set compile_c " /usr/bin/gcc -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c " +set compile_cxx " /usr/bin/g++ -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c " +set link " /usr/bin/g++ -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -g -L/Users/ddunbar/llvm.obj.64/Debug/lib -L/Volumes/Data/ddunbar/llvm.obj.64/Debug/lib " +set llvmgcc "/Users/ddunbar/llvm-gcc/install/bin/llvm-gcc -m64 " +set llvmgxx "/Users/ddunbar/llvm-gcc/install/bin/llvm-gcc -m64 " +set llvmgccmajvers "4" +set bugpoint_topts "-gcc-tool-args -m64" +set shlibext ".dylib" +set ocamlopt "/sw/bin/ocamlopt -cc \"g++ -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT\" -I /Users/ddunbar/llvm.obj.64/Debug/lib/ocaml" +set valgrind "" +set grep "/usr/bin/grep" +set gas "/usr/bin/as" +set llvmdsymutil "dsymutil" +## All variables above are generated by configure. Do Not Edit ## Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/lit.local.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/lit.local.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/lit.local.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1 @@ +config.excludes = ['src'] Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/Foo/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/Foo/lit.local.cfg?rev=86654&view=auto ============================================================================== (empty) Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/lit.site.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/lit.site.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/lit.site.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/lit.site.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,11 @@ +# -*- Python -*- + +## Autogenerated by Makefile ## +# Do not edit! + +# Preserve some key paths for use by main LLVM test suite config. +config.llvm_obj_root = os.path.dirname(os.path.dirname(__file__)) + +# Let the main config do the real work. +lit.load_config(config, os.path.join(config.llvm_obj_root, + '../src/test/lit.cfg')) Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/site.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/site.exp?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/site.exp (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/obj/test/site.exp Mon Nov 9 20:41:17 2009 @@ -0,0 +1,30 @@ +## these variables are automatically generated by make ## +# Do not edit here. If you wish to override these values +# edit the last section +set target_triplet "x86_64-apple-darwin10" +set TARGETS_TO_BUILD "X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend MSIL CppBackend" +set llvmgcc_langs "c,c++,objc,obj-c++" +set llvmgcc_version "4.2.1" +set prcontext "/usr/bin/tclsh8.4 /Volumes/Data/ddunbar/llvm/test/Scripts/prcontext.tcl" +set llvmtoolsdir "/Users/ddunbar/llvm.obj.64/Debug/bin" +set llvmlibsdir "/Users/ddunbar/llvm.obj.64/Debug/lib" +set srcroot "/Volumes/Data/ddunbar/llvm" +set objroot "/Volumes/Data/ddunbar/llvm.obj.64" +set srcdir "/Volumes/Data/ddunbar/llvm/test" +set objdir "/Volumes/Data/ddunbar/llvm.obj.64/test" +set gccpath "/usr/bin/gcc -arch x86_64" +set gxxpath "/usr/bin/g++ -arch x86_64" +set compile_c " /usr/bin/gcc -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c " +set compile_cxx " /usr/bin/g++ -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c " +set link " /usr/bin/g++ -arch x86_64 -I/Users/ddunbar/llvm.obj.64/include -I/Users/ddunbar/llvm.obj.64/test -I/Volumes/Data/ddunbar/llvm.obj.64/include -I/Volumes/Data/ddunbar/llvm/include -I/Volumes/Data/ddunbar/llvm/test -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -g -L/Users/ddunbar/llvm.obj.64/Debug/lib -L/Volumes/Data/ddunbar/llvm.obj.64/Debug/lib " +set llvmgcc "/Users/ddunbar/llvm-gcc/install/bin/llvm-gcc -m64 " +set llvmgxx "/Users/ddunbar/llvm-gcc/install/bin/llvm-gcc -m64 " +set llvmgccmajvers "4" +set bugpoint_topts "-gcc-tool-args -m64" +set shlibext ".dylib" +set ocamlopt "/sw/bin/ocamlopt -cc \"g++ -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT\" -I /Users/ddunbar/llvm.obj.64/Debug/lib/ocaml" +set valgrind "" +set grep "/usr/bin/grep" +set gas "/usr/bin/as" +set llvmdsymutil "dsymutil" +## All variables above are generated by configure. Do Not Edit ## Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/data.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/data.txt?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/data.txt (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/data.txt Mon Nov 9 20:41:17 2009 @@ -0,0 +1 @@ +hi Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/dg.exp?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/dg.exp (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/dg.exp Mon Nov 9 20:41:17 2009 @@ -0,0 +1,6 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} + Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/pct-S.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/pct-S.ll?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/pct-S.ll (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/Foo/pct-S.ll Mon Nov 9 20:41:17 2009 @@ -0,0 +1 @@ +; RUN: grep "hi" %S/data.txt \ No newline at end of file Added: llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/lit.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/lit.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/LLVM.OutOfTree/src/test/lit.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,151 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +import os + +# name: The name of this test suite. +config.name = 'LLVM' + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.TclTest() + +# suffixes: A list of file extensions to treat as test files, this is actually +# set by on_clone(). +config.suffixes = [] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root path where tests should be run. +llvm_obj_root = getattr(config, 'llvm_obj_root', None) +if llvm_obj_root is not None: + config.test_exec_root = os.path.join(llvm_obj_root, 'test') + +### + +import os + +# Check that the object root is known. +if config.test_exec_root is None: + # Otherwise, we haven't loaded the site specific configuration (the user is + # probably trying to run on a test file directly, and either the site + # configuration hasn't been created by the build system, or we are in an + # out-of-tree build situation). + + # Try to detect the situation where we are using an out-of-tree build by + # looking for 'llvm-config'. + # + # FIXME: I debated (i.e., wrote and threw away) adding logic to + # automagically generate the lit.site.cfg if we are in some kind of fresh + # build situation. This means knowing how to invoke the build system + # though, and I decided it was too much magic. + + llvm_config = lit.util.which('llvm-config', config.environment['PATH']) + if not llvm_config: + lit.fatal('No site specific configuration available!') + + # Get the source and object roots. + llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip() + llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip() + + # Validate that we got a tree which points to here. + this_src_root = os.path.dirname(config.test_source_root) + if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root): + lit.fatal('No site specific configuration available!') + + # Check that the site specific configuration exists. + site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg') + if not os.path.exists(site_cfg): + lit.fatal('No site specific configuration available!') + + # Okay, that worked. Notify the user of the automagic, and reconfigure. + lit.note('using out-of-tree build at %r' % llvm_obj_root) + lit.load_config(config, site_cfg) + raise SystemExit + +### + +# Load site data from DejaGNU's site.exp. +import re +site_exp = {} +# FIXME: Implement lit.site.cfg. +for line in open(os.path.join(config.llvm_obj_root, 'test', 'site.exp')): + m = re.match('set ([^ ]+) "([^"]*)"', line) + if m: + site_exp[m.group(1)] = m.group(2) + +# Add substitutions. +for sub in ['prcontext', 'llvmgcc', 'llvmgxx', 'compile_cxx', 'compile_c', + 'link', 'shlibext', 'ocamlopt', 'llvmdsymutil', 'llvmlibsdir', + 'bugpoint_topts']: + if sub in ('llvmgcc', 'llvmgxx'): + config.substitutions.append(('%' + sub, + site_exp[sub] + ' -emit-llvm -w')) + else: + config.substitutions.append(('%' + sub, site_exp[sub])) + +excludes = [] + +# Provide target_triple for use in XFAIL and XTARGET. +config.target_triple = site_exp['target_triplet'] + +# Provide llvm_supports_target for use in local configs. +targets = set(site_exp["TARGETS_TO_BUILD"].split()) +def llvm_supports_target(name): + return name in targets + +langs = set(site_exp['llvmgcc_langs'].split(',')) +def llvm_gcc_supports(name): + return name in langs + +# Provide on_clone hook for reading 'dg.exp'. +import os +simpleLibData = re.compile(r"""load_lib llvm.exp + +RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]""", + re.MULTILINE) +conditionalLibData = re.compile(r"""load_lib llvm.exp + +if.*\[ ?(llvm[^ ]*) ([^ ]*) ?\].*{ + *RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\] +\}""", re.MULTILINE) +def on_clone(parent, cfg, for_path): + def addSuffixes(match): + if match[0] == '{' and match[-1] == '}': + cfg.suffixes = ['.' + s for s in match[1:-1].split(',')] + else: + cfg.suffixes = ['.' + match] + + libPath = os.path.join(os.path.dirname(for_path), + 'dg.exp') + if not os.path.exists(libPath): + cfg.unsupported = True + return + + # Reset unsupported, in case we inherited it. + cfg.unsupported = False + lib = open(libPath).read().strip() + + # Check for a simple library. + m = simpleLibData.match(lib) + if m: + addSuffixes(m.group(1)) + return + + # Check for a conditional test set. + m = conditionalLibData.match(lib) + if m: + funcname,arg,match = m.groups() + addSuffixes(match) + + func = globals().get(funcname) + if not func: + lit.error('unsupported predicate %r' % funcname) + elif not func(arg): + cfg.unsupported = True + return + # Otherwise, give up. + lit.error('unable to understand %r:\n%s' % (libPath, lib)) + +config.on_clone = on_clone Added: llvm/trunk/utils/lit/ExampleTests/ShExternal/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/ShExternal/lit.local.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/ShExternal/lit.local.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/ShExternal/lit.local.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,6 @@ +# -*- Python -*- + +config.test_format = lit.formats.ShTest(execute_external = True) + +config.suffixes = ['.c'] + Added: llvm/trunk/utils/lit/ExampleTests/ShInternal/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/ShInternal/lit.local.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/ShInternal/lit.local.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/ShInternal/lit.local.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,6 @@ +# -*- Python -*- + +config.test_format = lit.formats.ShTest(execute_external = False) + +config.suffixes = ['.c'] + Added: llvm/trunk/utils/lit/ExampleTests/TclTest/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/TclTest/lit.local.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/TclTest/lit.local.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/TclTest/lit.local.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,5 @@ +# -*- Python -*- + +config.test_format = lit.formats.TclTest() + +config.suffixes = ['.ll'] Added: llvm/trunk/utils/lit/ExampleTests/TclTest/stderr-pipe.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/TclTest/stderr-pipe.ll?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/TclTest/stderr-pipe.ll (added) +++ llvm/trunk/utils/lit/ExampleTests/TclTest/stderr-pipe.ll Mon Nov 9 20:41:17 2009 @@ -0,0 +1 @@ +; RUN: gcc -### > /dev/null |& grep {gcc version} Added: llvm/trunk/utils/lit/ExampleTests/TclTest/tcl-redir-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/TclTest/tcl-redir-1.ll?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/TclTest/tcl-redir-1.ll (added) +++ llvm/trunk/utils/lit/ExampleTests/TclTest/tcl-redir-1.ll Mon Nov 9 20:41:17 2009 @@ -0,0 +1,7 @@ +; RUN: echo 'hi' > %t.1 | echo 'hello' > %t.2 +; RUN: not grep 'hi' %t.1 +; RUN: grep 'hello' %t.2 + + + + Added: llvm/trunk/utils/lit/ExampleTests/fail.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/fail.c?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/fail.c (added) +++ llvm/trunk/utils/lit/ExampleTests/fail.c Mon Nov 9 20:41:17 2009 @@ -0,0 +1,2 @@ +// RUN: echo 'I am some stdout' +// RUN: false Added: llvm/trunk/utils/lit/ExampleTests/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/lit.cfg?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/lit.cfg (added) +++ llvm/trunk/utils/lit/ExampleTests/lit.cfg Mon Nov 9 20:41:17 2009 @@ -0,0 +1,23 @@ +# -*- Python -*- + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'Examples' + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll'] + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.ShTest() + +# test_source_root: The path where tests are located (default is the test suite +# root). +config.test_source_root = None + +# test_exec_root: The path where tests are located (default is the test suite +# root). +config.test_exec_root = None + +# target_triple: Used by ShTest and TclTest formats for XFAIL checks. +config.target_triple = 'foo' Added: llvm/trunk/utils/lit/ExampleTests/pass.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/pass.c?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/pass.c (added) +++ llvm/trunk/utils/lit/ExampleTests/pass.c Mon Nov 9 20:41:17 2009 @@ -0,0 +1 @@ +// RUN: true Added: llvm/trunk/utils/lit/ExampleTests/xfail.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/xfail.c?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/xfail.c (added) +++ llvm/trunk/utils/lit/ExampleTests/xfail.c Mon Nov 9 20:41:17 2009 @@ -0,0 +1,2 @@ +// RUN: false +// XFAIL: * Added: llvm/trunk/utils/lit/ExampleTests/xpass.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/ExampleTests/xpass.c?rev=86654&view=auto ============================================================================== --- llvm/trunk/utils/lit/ExampleTests/xpass.c (added) +++ llvm/trunk/utils/lit/ExampleTests/xpass.c Mon Nov 9 20:41:17 2009 @@ -0,0 +1,2 @@ +// RUN: true +// XFAIL From daniel at zuster.org Mon Nov 9 20:41:27 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 02:41:27 -0000 Subject: [llvm-commits] [llvm] r86655 - /llvm/trunk/docs/CommandGuide/lit.pod Message-ID: <200911100241.nAA2fRBB012879@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Nov 9 20:41:27 2009 New Revision: 86655 URL: http://llvm.org/viewvc/llvm-project?rev=86655&view=rev Log: lit: Start documentation testing architecture. Modified: llvm/trunk/docs/CommandGuide/lit.pod Modified: llvm/trunk/docs/CommandGuide/lit.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lit.pod?rev=86655&r1=86654&r2=86655&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/lit.pod (original) +++ llvm/trunk/docs/CommandGuide/lit.pod Mon Nov 9 20:41:27 2009 @@ -36,6 +36,9 @@ the options specified on the command line, see L<"SELECTION OPTIONS"> for more information. +Users interested in the B architecture or designing a B testing +implementation should see L<"LIT ARCHITECTURE"> + =head1 GENERAL OPTIONS =over @@ -222,6 +225,119 @@ their status (generally only for failures). See the L section for more information. +=head1 LIT INFRASTRUCTURE + +This section describes the B testing architecture for users interested in +creating a new B testing implementation, or extending an existing one. + +B proper is primarily an infrastructure for discovering and running +arbitrary tests, and to expose a single convenient interface to these +tests. B itself doesn't contain know how to run tests, rather this logic is +defined by I. + +=head2 TEST SUITES + +As described in L<"TEST DISCOVERY">, tests are always located inside a I. Test suites serve to define the format of the tests they contain, the +logic for finding those tests, and any additional information to run the tests. + +B identifies test suites as directories containing I or +I files (see also B<--config-prefix>. Test suites are initially +discovered by recursively searching up the directory hierarchy for all the input +files passed on the command line. You can use B<--show-suites> to display the +discovered test suites at startup. + +Once a test suite is discovered, its config file is loaded. Config files +themselves are just Python modules which will be executed. When the config file +is executed, two important global variables are predefined: + +=over + +=item B + +The global B configuration object (a I instance), which defines +the builtin test formats, global configuration parameters, and other helper +routines for implementing test configurations. + +=item B + +This is the config object (a I instance) for the test suite, +which the config file is expected to populate. The following variables are also +available on the I object, some of which must be set by the config and +others are optional or predefined: + +B I<[required]> The name of the test suite, for use in reports and +diagnostics. + +B I<[required]> The test format object which will be used to +discover and run tests in the test suite. Generally this will be a builtin test +format available from the I module. + +B The filesystem path to the test suite root. For out-of-dir +builds this is the directory that will be scanned for tests. + +B For out-of-dir builds, the path to the test suite root inside +the object directory. This is where tests will be run and temporary output files +places. + +B A dictionary representing the environment to use when executing +tests in the suite. + +B For B test formats which scan directories for tests, this +variable as a list of suffixes to identify test files. Used by: I, +I. + +B For B test formats which substitute variables into a test +script, the list of substitutions to perform. Used by: I, I. + +B Mark an unsupported directory, all tests within it will be +reported as unsupported. Used by: I, I. + +B The parent configuration, this is the config object for the directory +containing the test suite, or None. + +B The config is actually cloned for every subdirectory inside a test +suite, to allow local configuration on a per-directory basis. The I +variable can be set to a Python function which will be called whenever a +configuration is cloned (for a subdirectory). The function should takes three +arguments: (1) the parent configuration, (2) the new configuration (which the +I function will generally modify), and (3) the test path to the new +directory being scanned. + +=back + +=head2 TEST DISCOVERY + +Once test suites are located, B recursively traverses the source directory +(following I) looking for tests. When B enters a +sub-directory, it first checks to see if a nest test suite is defined in that +directory. If so, it loads that test suite recursively, otherwise it +instantiates a local test config for the directory (see L<"LOCAL CONFIGURATION +FILES">). + +Tests are identified by the test suite they are contained within, and the +relative path inside that suite. Note that the relative path may not refer to an +actual file on disk; some test formats (such as I) define "virtual +tests" which have a path that contains both the path to the actual test file and +a subpath to identify the virtual test. + +=head2 LOCAL CONFIGURATION FILES + +When B loads a subdirectory in a test suite, it instantiates a local test +configuration by cloning the configuration for the parent direction -- the root +of this configuration chain will always be a test suite. Once the test +configuration is cloned B checks for a I file in the +subdirectory. If present, this file will be loaded and can be used to specialize +the configuration for each individual directory. This facility can be used to +define subdirectories of optional tests, or to change other configuration +parameters -- for example, to change the test format, or the suffixes which +identify test files. + +=head2 LIT EXAMPLE TESTS + +The B distribution contains several example implementations of test suites +in the I directory. + =head1 SEE ALSO L From kennethuil at gmail.com Mon Nov 9 20:42:39 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 9 Nov 2009 20:42:39 -0600 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> Message-ID: <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> Here's the updated version of the patch: 1. Moved the flag and demote register from MachineFunction to FunctionLoweringInfo 2. Inverted CantLowerReturn to CanLowerReturn while carrying out #1 3. Now passing the return Attributes to getReturnInfo and using its ZExt and SExt flags properly. 4. Cleaned up braces. New testcase coming as soon as I figure out how to get svn diff or mkpatch to pick up a brand-new file. -------------- next part -------------- A non-text attachment was scrubbed... Name: sret-demote.patch Type: text/x-patch Size: 16182 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/9bd1fa87/attachment.bin From ofv at wanadoo.es Mon Nov 9 20:45:37 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 10 Nov 2009 02:45:37 -0000 Subject: [llvm-commits] [llvm] r86656 - in /llvm/trunk: cmake/modules/AddLLVM.cmake cmake/modules/LLVMLibDeps.cmake lib/Transforms/Hello/CMakeLists.txt Message-ID: <200911100245.nAA2jbb4013035@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 9 20:45:37 2009 New Revision: 86656 URL: http://llvm.org/viewvc/llvm-project?rev=86656&view=rev Log: CMake: Support for building llvm loadable modules. Modified: llvm/trunk/cmake/modules/AddLLVM.cmake llvm/trunk/cmake/modules/LLVMLibDeps.cmake llvm/trunk/lib/Transforms/Hello/CMakeLists.txt Modified: llvm/trunk/cmake/modules/AddLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=86656&r1=86655&r2=86656&view=diff ============================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake (original) +++ llvm/trunk/cmake/modules/AddLLVM.cmake Mon Nov 9 20:45:37 2009 @@ -22,6 +22,22 @@ endmacro(add_llvm_library name) +macro(add_llvm_loadable_module name) + if( NOT LLVM_ON_UNIX ) + message(STATUS "Loadable modules not supported on this platform. +${name} ignored.") + else() + set(BUILD_SHARED_LIBS ON) + llvm_process_sources( ALL_FILES ${ARGN} ) + add_library( ${name} MODULE ${ALL_FILES} ) + set_target_properties( ${name} PROPERTIES PREFIX "" ) + install(TARGETS ${name} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() +endmacro(add_llvm_loadable_module name) + + macro(add_llvm_executable name) llvm_process_sources( ALL_FILES ${ARGN} ) add_executable(${name} ${ALL_FILES}) Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=86656&r1=86655&r2=86656&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Mon Nov 9 20:45:37 2009 @@ -24,7 +24,6 @@ set(MSVC_LIB_DEPS_LLVMCppBackend LLVMCore LLVMCppBackendInfo LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMCppBackendInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMExecutionEngine LLVMCore LLVMSupport LLVMSystem LLVMTarget) -set(MSVC_LIB_DEPS_LLVMHello LLVMCore LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMInstrumentation LLVMAnalysis LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTransformUtils) set(MSVC_LIB_DEPS_LLVMInterpreter LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMJIT LLVMCodeGen LLVMCore LLVMExecutionEngine LLVMMC LLVMSupport LLVMSystem LLVMTarget) Modified: llvm/trunk/lib/Transforms/Hello/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Hello/CMakeLists.txt?rev=86656&r1=86655&r2=86656&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Hello/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Hello/CMakeLists.txt Mon Nov 9 20:45:37 2009 @@ -1,3 +1,3 @@ -add_llvm_library( LLVMHello +add_llvm_loadable_module( LLVMHello Hello.cpp ) From baldrick at free.fr Mon Nov 9 20:49:07 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 03:49:07 +0100 Subject: [llvm-commits] [llvm] r86603 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp In-Reply-To: <200911092232.nA9MWbu6002598@zion.cs.uiuc.edu> References: <200911092232.nA9MWbu6002598@zion.cs.uiuc.edu> Message-ID: <4AF8D4A3.60409@free.fr> Hi Chris, > + // This only adjusts blocks with PHI nodes. > + if (!isa(BB->begin())) > + return; don't you still want to do BB->removePredecessor in this case? Anyway, if the BB doesn't start with a phi, the following code does essentially nothing anyway, so the test doesn't buy you much. > + //BB->removePredecessor(Pred, true); > + BB->removePredecessor(Pred, true); One of these shouldn't be there :) Also, this seems like a generally useful transform - does it really belong in JumpThreading? Ciao, Duncan. From baldrick at free.fr Mon Nov 9 20:58:24 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 03:58:24 +0100 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> Message-ID: <4AF8D6D0.4010108@free.fr> > New testcase coming as soon as I figure out how to get svn diff or > mkpatch to pick up a brand-new file. First do "svn add" on the new file. Ciao, Duncan. From kennethuil at gmail.com Mon Nov 9 21:06:07 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 9 Nov 2009 21:06:07 -0600 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <4AF8D6D0.4010108@free.fr> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> <4AF8D6D0.4010108@free.fr> Message-ID: <400d33ea0911091906md1d6cdeva01ae53e6b3b18af@mail.gmail.com> Thanks! -------------- next part -------------- A non-text attachment was scrubbed... Name: sret-demote-tests.patch Type: text/x-patch Size: 699 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091109/f2b1c70b/attachment.bin From baldrick at free.fr Mon Nov 9 21:08:54 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 04:08:54 +0100 Subject: [llvm-commits] [llvm] r86646 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll In-Reply-To: <200911100157.nAA1vWM3011198@zion.cs.uiuc.edu> References: <200911100157.nAA1vWM3011198@zion.cs.uiuc.edu> Message-ID: <4AF8D946.90606@free.fr> Hi Chris, > + Instruction *User = cast(U.getUser()); > + U = To; this assignment doesn't seem to be useful. Ciao, Duncan. From sabre at nondot.org Mon Nov 9 23:09:25 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 9 Nov 2009 21:09:25 -0800 Subject: [llvm-commits] [llvm] r86603 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp In-Reply-To: <4AF8D4A3.60409@free.fr> References: <200911092232.nA9MWbu6002598@zion.cs.uiuc.edu> <4AF8D4A3.60409@free.fr> Message-ID: <2F6BAA6A-0C04-4189-9FB5-ACFDC4D3C776@nondot.org> On Nov 9, 2009, at 6:49 PM, Duncan Sands wrote: > Hi Chris, > >> + // This only adjusts blocks with PHI nodes. >> + if (!isa(BB->begin())) >> + return; > > don't you still want to do BB->removePredecessor in this case? it's a noop in this case too. > Anyway, if the BB doesn't start with a phi, the following code does > essentially > nothing anyway, so the test doesn't buy you much. Most blocks don't have phis, so it's a small optimization. > >> + //BB->removePredecessor(Pred, true); >> + BB->removePredecessor(Pred, true); > > One of these shouldn't be there :) Already gone. > > Also, this seems like a generally useful transform - does it really > belong > in JumpThreading? No, but I will refactor it in time, no worries :) -Chris From sabre at nondot.org Mon Nov 9 23:09:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 9 Nov 2009 21:09:58 -0800 Subject: [llvm-commits] [llvm] r86646 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll In-Reply-To: <4AF8D946.90606@free.fr> References: <200911100157.nAA1vWM3011198@zion.cs.uiuc.edu> <4AF8D946.90606@free.fr> Message-ID: <290E5D6E-986E-49C3-B17A-1A06C9944EB2@nondot.org> On Nov 9, 2009, at 7:08 PM, Duncan Sands wrote: > Hi Chris, > >> + Instruction *User = cast(U.getUser()); >> + U = To; > > this assignment doesn't seem to be useful. It is equivalent to User->setOperand(U.getOperandNo(), To) but a lot faster :) -Chris From clattner at apple.com Mon Nov 9 23:16:41 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Nov 2009 21:16:41 -0800 Subject: [llvm-commits] [llvm] r86651 - /llvm/trunk/lib/Target/Mips/MipsInstrFPU.td In-Reply-To: <200911100235.nAA2ZERO012563@zion.cs.uiuc.edu> References: <200911100235.nAA2ZERO012563@zion.cs.uiuc.edu> Message-ID: On Nov 9, 2009, at 6:35 PM, Bruno Cardoso Lopes wrote: > Author: bruno > Date: Mon Nov 9 20:35:13 2009 > New Revision: 86651 > > URL: http://llvm.org/viewvc/llvm-project?rev=86651&view=rev > Log: > Fix PR5445 Hey Bruno, FYI -0.0 is not the same as 0.0. -Chris > > Modified: > llvm/trunk/lib/Target/Mips/MipsInstrFPU.td > > Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=86651&r1=86650&r2=86651&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) > +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Mon Nov 9 20:35:13 > 2009 > @@ -281,7 +281,7 @@ > // Floating Point Patterns > // > = > = > = > ----------------------------------------------------------------------= > ==// > def fpimm0 : PatLeaf<(fpimm), [{ > - return N->isExactlyValue(+0.0); > + return N->isExactlyValue(+0.0) || N->isExactlyValue(-0.0); > }]>; > > def : Pat<(f32 fpimm0), (MTC1 ZERO)>; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Nov 9 23:59:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 05:59:27 -0000 Subject: [llvm-commits] [llvm] r86666 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Utils/Local.cpp lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200911100559.nAA5xRel019811@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 9 23:59:26 2009 New Revision: 86666 URL: http://llvm.org/viewvc/llvm-project?rev=86666&view=rev Log: refactor TryToSimplifyUncondBranchFromEmptyBlock out of SimplifyCFG. Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=86666&r1=86665&r2=86666&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Mon Nov 9 23:59:26 2009 @@ -85,7 +85,14 @@ /// void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, Pass *P = 0); - + +/// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an +/// unconditional branch, and contains no instructions other than PHI nodes, +/// potential debug intrinsics and the branch. If possible, eliminate BB by +/// rewriting all the predecessors to branch to the successor block and return +/// true. If we can't transform, return false. +bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB); + /// SimplifyCFG - This function is used to do simplification of a CFG. For /// example, it adjusts branches to branches to eliminate the extra hop, it /// eliminates unreachable basic blocks, and does other "peephole" optimization Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=86666&r1=86665&r2=86666&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Nov 9 23:59:26 2009 @@ -26,8 +26,11 @@ #include "llvm/Analysis/DebugInfo.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Target/TargetData.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -362,6 +365,174 @@ PredBB->eraseFromParent(); } +/// CanPropagatePredecessorsForPHIs - Return true if we can fold BB, an +/// almost-empty BB ending in an unconditional branch to Succ, into succ. +/// +/// Assumption: Succ is the single successor for BB. +/// +static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { + assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!"); + + DEBUG(errs() << "Looking to fold " << BB->getName() << " into " + << Succ->getName() << "\n"); + // Shortcut, if there is only a single predecessor it must be BB and merging + // is always safe + if (Succ->getSinglePredecessor()) return true; + + // Make a list of the predecessors of BB + typedef SmallPtrSet BlockSet; + BlockSet BBPreds(pred_begin(BB), pred_end(BB)); + + // Use that list to make another list of common predecessors of BB and Succ + BlockSet CommonPreds; + for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ); + PI != PE; ++PI) + if (BBPreds.count(*PI)) + CommonPreds.insert(*PI); + + // Shortcut, if there are no common predecessors, merging is always safe + if (CommonPreds.empty()) + return true; + + // Look at all the phi nodes in Succ, to see if they present a conflict when + // merging these blocks + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode *PN = cast(I); + + // If the incoming value from BB is again a PHINode in + // BB which has the same incoming value for *PI as PN does, we can + // merge the phi nodes and then the blocks can still be merged + PHINode *BBPN = dyn_cast(PN->getIncomingValueForBlock(BB)); + if (BBPN && BBPN->getParent() == BB) { + for (BlockSet::iterator PI = CommonPreds.begin(), PE = CommonPreds.end(); + PI != PE; PI++) { + if (BBPN->getIncomingValueForBlock(*PI) + != PN->getIncomingValueForBlock(*PI)) { + DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in " + << Succ->getName() << " is conflicting with " + << BBPN->getName() << " with regard to common predecessor " + << (*PI)->getName() << "\n"); + return false; + } + } + } else { + Value* Val = PN->getIncomingValueForBlock(BB); + for (BlockSet::iterator PI = CommonPreds.begin(), PE = CommonPreds.end(); + PI != PE; PI++) { + // See if the incoming value for the common predecessor is equal to the + // one for BB, in which case this phi node will not prevent the merging + // of the block. + if (Val != PN->getIncomingValueForBlock(*PI)) { + DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in " + << Succ->getName() << " is conflicting with regard to common " + << "predecessor " << (*PI)->getName() << "\n"); + return false; + } + } + } + } + + return true; +} + +/// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an +/// unconditional branch, and contains no instructions other than PHI nodes, +/// potential debug intrinsics and the branch. If possible, eliminate BB by +/// rewriting all the predecessors to branch to the successor block and return +/// true. If we can't transform, return false. +bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB) { + // We can't eliminate infinite loops. + BasicBlock *Succ = cast(BB->getTerminator())->getSuccessor(0); + if (BB == Succ) return false; + + // Check to see if merging these blocks would cause conflicts for any of the + // phi nodes in BB or Succ. If not, we can safely merge. + if (!CanPropagatePredecessorsForPHIs(BB, Succ)) return false; + + // Check for cases where Succ has multiple predecessors and a PHI node in BB + // has uses which will not disappear when the PHI nodes are merged. It is + // possible to handle such cases, but difficult: it requires checking whether + // BB dominates Succ, which is non-trivial to calculate in the case where + // Succ has multiple predecessors. Also, it requires checking whether + // constructing the necessary self-referential PHI node doesn't intoduce any + // conflicts; this isn't too difficult, but the previous code for doing this + // was incorrect. + // + // Note that if this check finds a live use, BB dominates Succ, so BB is + // something like a loop pre-header (or rarely, a part of an irreducible CFG); + // folding the branch isn't profitable in that case anyway. + if (!Succ->getSinglePredecessor()) { + BasicBlock::iterator BBI = BB->begin(); + while (isa(*BBI)) { + for (Value::use_iterator UI = BBI->use_begin(), E = BBI->use_end(); + UI != E; ++UI) { + if (PHINode* PN = dyn_cast(*UI)) { + if (PN->getIncomingBlock(UI) != BB) + return false; + } else { + return false; + } + } + ++BBI; + } + } + + DEBUG(errs() << "Killing Trivial BB: \n" << *BB); + + if (isa(Succ->begin())) { + // If there is more than one pred of succ, and there are PHI nodes in + // the successor, then we need to add incoming edges for the PHI nodes + // + const SmallVector BBPreds(pred_begin(BB), pred_end(BB)); + + // Loop over all of the PHI nodes in the successor of BB. + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode *PN = cast(I); + Value *OldVal = PN->removeIncomingValue(BB, false); + assert(OldVal && "No entry in PHI for Pred BB!"); + + // If this incoming value is one of the PHI nodes in BB, the new entries + // in the PHI node are the entries from the old PHI. + if (isa(OldVal) && cast(OldVal)->getParent() == BB) { + PHINode *OldValPN = cast(OldVal); + for (unsigned i = 0, e = OldValPN->getNumIncomingValues(); i != e; ++i) + // Note that, since we are merging phi nodes and BB and Succ might + // have common predecessors, we could end up with a phi node with + // identical incoming branches. This will be cleaned up later (and + // will trigger asserts if we try to clean it up now, without also + // simplifying the corresponding conditional branch). + PN->addIncoming(OldValPN->getIncomingValue(i), + OldValPN->getIncomingBlock(i)); + } else { + // Add an incoming value for each of the new incoming values. + for (unsigned i = 0, e = BBPreds.size(); i != e; ++i) + PN->addIncoming(OldVal, BBPreds[i]); + } + } + } + + while (PHINode *PN = dyn_cast(&BB->front())) { + if (Succ->getSinglePredecessor()) { + // BB is the only predecessor of Succ, so Succ will end up with exactly + // the same predecessors BB had. + Succ->getInstList().splice(Succ->begin(), + BB->getInstList(), BB->begin()); + } else { + // We explicitly check for such uses in CanPropagatePredecessorsForPHIs. + assert(PN->use_empty() && "There shouldn't be any uses here!"); + PN->eraseFromParent(); + } + } + + // Everything that jumped to BB now goes to Succ. + BB->replaceAllUsesWith(Succ); + if (!Succ->hasName()) Succ->takeName(BB); + BB->eraseFromParent(); // Delete the old basic block. + return true; +} + + + /// OnlyUsedByDbgIntrinsics - Return true if the instruction I is only used /// by DbgIntrinsics. If DbgInUses is specified then the vector is filled /// with the DbgInfoIntrinsic that use the instruction I. Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=86666&r1=86665&r2=86666&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Nov 9 23:59:26 2009 @@ -78,166 +78,6 @@ PN->addIncoming(PN->getIncomingValueForBlock(ExistPred), NewPred); } -/// CanPropagatePredecessorsForPHIs - Return true if we can fold BB, an -/// almost-empty BB ending in an unconditional branch to Succ, into succ. -/// -/// Assumption: Succ is the single successor for BB. -/// -static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { - assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!"); - - DEBUG(errs() << "Looking to fold " << BB->getName() << " into " - << Succ->getName() << "\n"); - // Shortcut, if there is only a single predecessor it must be BB and merging - // is always safe - if (Succ->getSinglePredecessor()) return true; - - // Make a list of the predecessors of BB - typedef SmallPtrSet BlockSet; - BlockSet BBPreds(pred_begin(BB), pred_end(BB)); - - // Use that list to make another list of common predecessors of BB and Succ - BlockSet CommonPreds; - for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ); - PI != PE; ++PI) - if (BBPreds.count(*PI)) - CommonPreds.insert(*PI); - - // Shortcut, if there are no common predecessors, merging is always safe - if (CommonPreds.empty()) - return true; - - // Look at all the phi nodes in Succ, to see if they present a conflict when - // merging these blocks - for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { - PHINode *PN = cast(I); - - // If the incoming value from BB is again a PHINode in - // BB which has the same incoming value for *PI as PN does, we can - // merge the phi nodes and then the blocks can still be merged - PHINode *BBPN = dyn_cast(PN->getIncomingValueForBlock(BB)); - if (BBPN && BBPN->getParent() == BB) { - for (BlockSet::iterator PI = CommonPreds.begin(), PE = CommonPreds.end(); - PI != PE; PI++) { - if (BBPN->getIncomingValueForBlock(*PI) - != PN->getIncomingValueForBlock(*PI)) { - DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in " - << Succ->getName() << " is conflicting with " - << BBPN->getName() << " with regard to common predecessor " - << (*PI)->getName() << "\n"); - return false; - } - } - } else { - Value* Val = PN->getIncomingValueForBlock(BB); - for (BlockSet::iterator PI = CommonPreds.begin(), PE = CommonPreds.end(); - PI != PE; PI++) { - // See if the incoming value for the common predecessor is equal to the - // one for BB, in which case this phi node will not prevent the merging - // of the block. - if (Val != PN->getIncomingValueForBlock(*PI)) { - DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in " - << Succ->getName() << " is conflicting with regard to common " - << "predecessor " << (*PI)->getName() << "\n"); - return false; - } - } - } - } - - return true; -} - -/// TryToSimplifyUncondBranchFromEmptyBlock - BB contains an unconditional -/// branch to Succ, and contains no instructions other than PHI nodes and the -/// branch. If possible, eliminate BB. -static bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB, - BasicBlock *Succ) { - // Check to see if merging these blocks would cause conflicts for any of the - // phi nodes in BB or Succ. If not, we can safely merge. - if (!CanPropagatePredecessorsForPHIs(BB, Succ)) return false; - - // Check for cases where Succ has multiple predecessors and a PHI node in BB - // has uses which will not disappear when the PHI nodes are merged. It is - // possible to handle such cases, but difficult: it requires checking whether - // BB dominates Succ, which is non-trivial to calculate in the case where - // Succ has multiple predecessors. Also, it requires checking whether - // constructing the necessary self-referential PHI node doesn't intoduce any - // conflicts; this isn't too difficult, but the previous code for doing this - // was incorrect. - // - // Note that if this check finds a live use, BB dominates Succ, so BB is - // something like a loop pre-header (or rarely, a part of an irreducible CFG); - // folding the branch isn't profitable in that case anyway. - if (!Succ->getSinglePredecessor()) { - BasicBlock::iterator BBI = BB->begin(); - while (isa(*BBI)) { - for (Value::use_iterator UI = BBI->use_begin(), E = BBI->use_end(); - UI != E; ++UI) { - if (PHINode* PN = dyn_cast(*UI)) { - if (PN->getIncomingBlock(UI) != BB) - return false; - } else { - return false; - } - } - ++BBI; - } - } - - DEBUG(errs() << "Killing Trivial BB: \n" << *BB); - - if (isa(Succ->begin())) { - // If there is more than one pred of succ, and there are PHI nodes in - // the successor, then we need to add incoming edges for the PHI nodes - // - const SmallVector BBPreds(pred_begin(BB), pred_end(BB)); - - // Loop over all of the PHI nodes in the successor of BB. - for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { - PHINode *PN = cast(I); - Value *OldVal = PN->removeIncomingValue(BB, false); - assert(OldVal && "No entry in PHI for Pred BB!"); - - // If this incoming value is one of the PHI nodes in BB, the new entries - // in the PHI node are the entries from the old PHI. - if (isa(OldVal) && cast(OldVal)->getParent() == BB) { - PHINode *OldValPN = cast(OldVal); - for (unsigned i = 0, e = OldValPN->getNumIncomingValues(); i != e; ++i) - // Note that, since we are merging phi nodes and BB and Succ might - // have common predecessors, we could end up with a phi node with - // identical incoming branches. This will be cleaned up later (and - // will trigger asserts if we try to clean it up now, without also - // simplifying the corresponding conditional branch). - PN->addIncoming(OldValPN->getIncomingValue(i), - OldValPN->getIncomingBlock(i)); - } else { - // Add an incoming value for each of the new incoming values. - for (unsigned i = 0, e = BBPreds.size(); i != e; ++i) - PN->addIncoming(OldVal, BBPreds[i]); - } - } - } - - while (PHINode *PN = dyn_cast(&BB->front())) { - if (Succ->getSinglePredecessor()) { - // BB is the only predecessor of Succ, so Succ will end up with exactly - // the same predecessors BB had. - Succ->getInstList().splice(Succ->begin(), - BB->getInstList(), BB->begin()); - } else { - // We explicitly check for such uses in CanPropagatePredecessorsForPHIs. - assert(PN->use_empty() && "There shouldn't be any uses here!"); - PN->eraseFromParent(); - } - } - - // Everything that jumped to BB now goes to Succ. - BB->replaceAllUsesWith(Succ); - if (!Succ->hasName()) Succ->takeName(BB); - BB->eraseFromParent(); // Delete the old basic block. - return true; -} /// GetIfCondition - Given a basic block (BB) with two predecessors (and /// presumably PHI nodes in it), check to see if the merge at this block is due @@ -1983,13 +1823,11 @@ if (BI->isUnconditional()) { BasicBlock::iterator BBI = BB->getFirstNonPHI(); - BasicBlock *Succ = BI->getSuccessor(0); // Ignore dbg intrinsics. while (isa(BBI)) ++BBI; - if (BBI->isTerminator() && // Terminator is the only non-phi instruction! - Succ != BB) // Don't hurt infinite loops! - if (TryToSimplifyUncondBranchFromEmptyBlock(BB, Succ)) + if (BBI->isTerminator()) // Terminator is the only non-phi instruction! + if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) return true; } else { // Conditional branch From evan.cheng at apple.com Tue Nov 10 00:38:48 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 9 Nov 2009 22:38:48 -0800 Subject: [llvm-commits] Question on emitLoadStoreInstruction() of ARMCodeEmitter.cpp In-Reply-To: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> References: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> Message-ID: <1098E54E-0B98-4E3F-BE64-25CE8A9883F4@apple.com> On Nov 9, 2009, at 5:46 PM, Johnny Chen wrote: > > Hi, > > I have a question wrt the following fragment of code: > > // Operand 0 of a pre- and post-indexed store is the address base > // writeback. Skip it. > bool Skipped = false; > if (IsPrePost && Form == ARMII::StFrm) { > ++OpIdx; > Skipped = true; > } > > // Set first operand > if (ImplicitRd) > // Special handling for implicit use (e.g. PC). > Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd) > << ARMII::RegRdShift); > else > Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; > > and from the Record definition of LDRB_POST: > > def LDRB_POST { // Instruction InstARM I AI2ldbpo > field bits<32> Inst = { ?, ?, ?, ?, 0, 1, ?, 0, ?, 1, 0, > 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? }; > string Namespace = "ARM"; > dag OutOperandList = (outs GPR:$dst, GPR:$base_wb); > dag InOperandList = (ins GPR:$base, am2offset:$offset, pred:$p); > string AsmString = "ldrb${p} $dst, [$base], $offset"; > > it looks like the processing of "address base writeback" should > happen after the processing of RegRd, > if the ordering of OutOperandList followed by InOperandList is to be > observed. Is my understanding of > the ordering of the MachineOperands correct? Right. Defs comes first followed by uses. > > If this is the case, then there could be some bug in the codegen > which compensates for the incorrect > ordering/processing of base_writeback/dst? No. It's fine. The second operand is base_wb, base will be skipped. Evan > > Thanks. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Tue Nov 10 00:46:40 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 10 Nov 2009 06:46:40 -0000 Subject: [llvm-commits] [llvm] r86667 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/lifetime.ll test/Transforms/DeadStoreElimination/memintrinsics.ll test/Transforms/DeadStoreElimination/partial-overwrite.ll Message-ID: <200911100646.nAA6kf2k021721@zion.cs.uiuc.edu> Author: nicholas Date: Tue Nov 10 00:46:40 2009 New Revision: 86667 URL: http://llvm.org/viewvc/llvm-project?rev=86667&view=rev Log: Reapply r86359, "Teach dead store elimination that certain intrinsics write to memory just like a store" with bug fixed (partial-overwrite.ll is the regression test). Added: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll llvm/trunk/test/Transforms/DeadStoreElimination/partial-overwrite.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86667&r1=86666&r2=86667&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 10 00:46:40 2009 @@ -78,19 +78,84 @@ FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); } -/// isValueAtLeastAsBigAs - Return true if V1 is greater than or equal to the -/// stored size of V2. This returns false if we don't know. +/// doesClobberMemory - Does this instruction clobber (write without reading) +/// some memory? +static bool doesClobberMemory(Instruction *I) { + if (isa(I)) + return true; + if (IntrinsicInst *II = dyn_cast(I)) { + switch (II->getIntrinsicID()) { + default: return false; + case Intrinsic::memset: case Intrinsic::memmove: case Intrinsic::memcpy: + case Intrinsic::lifetime_end: return true; + } + } + return false; +} + +/// isElidable - If the memory this instruction and the memory it writes to is +/// unused, may we delete this instrtction? +static bool isElidable(Instruction *I) { + assert(doesClobberMemory(I)); + if (IntrinsicInst *II = dyn_cast(I)) + return II->getIntrinsicID() != Intrinsic::lifetime_end; + if (StoreInst *SI = dyn_cast(I)) + return !SI->isVolatile(); + return true; +} + +/// getPointerOperand - Return the pointer that is being clobbered. +static Value *getPointerOperand(Instruction *I) { + assert(doesClobberMemory(I)); + if (StoreInst *SI = dyn_cast(I)) + return SI->getPointerOperand(); + if (MemIntrinsic *MI = dyn_cast(I)) + return MI->getOperand(1); + assert(cast(I)->getIntrinsicID() == Intrinsic::lifetime_end); + return cast(I)->getOperand(2); +} + +/// getStoreSize - Return the length in bytes of the write by the clobbering +/// instruction. If variable or unknown, returns -1. +static unsigned getStoreSize(Instruction *I, const TargetData *TD) { + assert(doesClobberMemory(I)); + if (StoreInst *SI = dyn_cast(I)) { + if (!TD) return -1u; + const PointerType *PTy = + cast(SI->getPointerOperand()->getType()); + return TD->getTypeStoreSize(PTy->getElementType()); + } + + Value *Len; + if (MemIntrinsic *MI = dyn_cast(I)) { + Len = MI->getLength(); + } else { + IntrinsicInst *II = cast(I); + assert(II->getIntrinsicID() == Intrinsic::lifetime_end); + Len = II->getOperand(0); + } + if (ConstantInt *LenCI = dyn_cast(Len)) + if (!LenCI->isAllOnesValue()) + return LenCI->getZExtValue(); + return -1u; +} + +/// isStoreAtLeastAsWideAs - Return true if the size of the store in I1 is +/// greater than or equal to the store in I2. This returns false if we don't +/// know. /// -static bool isValueAtLeastAsBigAs(Value *V1, Value *V2, const TargetData *TD) { - const Type *V1Ty = V1->getType(), *V2Ty = V2->getType(); +static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2, + const TargetData *TD) { + const Type *I1Ty = getPointerOperand(I1)->getType(); + const Type *I2Ty = getPointerOperand(I2)->getType(); // Exactly the same type, must have exactly the same size. - if (V1Ty == V2Ty) return true; + if (I1Ty == I2Ty) return true; - // If we don't have target data, we don't know. - if (TD == 0) return false; + int I1Size = getStoreSize(I1, TD); + int I2Size = getStoreSize(I2, TD); - return TD->getTypeStoreSize(V1Ty) >= TD->getTypeStoreSize(V2Ty); + return I1Size != -1 && I2Size != -1 && I1Size >= I2Size; } bool DSE::runOnBasicBlock(BasicBlock &BB) { @@ -104,14 +169,9 @@ Instruction *Inst = BBI++; // If we find a store or a free, get its memory dependence. - if (!isa(Inst) && !isFreeCall(Inst)) + if (!doesClobberMemory(Inst) && !isFreeCall(Inst)) continue; - // Don't molest volatile stores or do queries that will return "clobber". - if (StoreInst *SI = dyn_cast(Inst)) - if (SI->isVolatile()) - continue; - MemDepResult InstDep = MD.getDependency(Inst); // Ignore non-local stores. @@ -124,16 +184,16 @@ continue; } - StoreInst *SI = cast(Inst); - // If not a definite must-alias dependency, ignore it. if (!InstDep.isDef()) continue; // If this is a store-store dependence, then the previous store is dead so // long as this store is at least as big as it. - if (StoreInst *DepStore = dyn_cast(InstDep.getInst())) - if (isValueAtLeastAsBigAs(SI->getOperand(0), DepStore->getOperand(0),TD)){ + if (doesClobberMemory(InstDep.getInst())) { + Instruction *DepStore = InstDep.getInst(); + if (isStoreAtLeastAsWideAs(Inst, DepStore, TD) && + isElidable(DepStore)) { // Delete the store and now-dead instructions that feed it. DeleteDeadInstruction(DepStore); NumFastStores++; @@ -146,37 +206,43 @@ --BBI; continue; } + } + + if (!isElidable(Inst)) + continue; // If we're storing the same value back to a pointer that we just // loaded from, then the store can be removed. - if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { - if (SI->getPointerOperand() == DepLoad->getPointerOperand() && - SI->getOperand(0) == DepLoad) { - // DeleteDeadInstruction can delete the current instruction. Save BBI - // in case we need it. - WeakVH NextInst(BBI); - - DeleteDeadInstruction(SI); - - if (NextInst == 0) // Next instruction deleted. - BBI = BB.begin(); - else if (BBI != BB.begin()) // Revisit this instruction if possible. - --BBI; - NumFastStores++; - MadeChange = true; - continue; + if (StoreInst *SI = dyn_cast(Inst)) { + if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { + if (SI->getPointerOperand() == DepLoad->getPointerOperand() && + SI->getOperand(0) == DepLoad) { + // DeleteDeadInstruction can delete the current instruction. Save BBI + // in case we need it. + WeakVH NextInst(BBI); + + DeleteDeadInstruction(SI); + + if (NextInst == 0) // Next instruction deleted. + BBI = BB.begin(); + else if (BBI != BB.begin()) // Revisit this instruction if possible. + --BBI; + NumFastStores++; + MadeChange = true; + continue; + } } } // If this is a lifetime end marker, we can throw away the store. - if (IntrinsicInst* II = dyn_cast(InstDep.getInst())) { + if (IntrinsicInst *II = dyn_cast(InstDep.getInst())) { if (II->getIntrinsicID() == Intrinsic::lifetime_end) { // Delete the store and now-dead instructions that feed it. // DeleteDeadInstruction can delete the current instruction. Save BBI // in case we need it. WeakVH NextInst(BBI); - DeleteDeadInstruction(SI); + DeleteDeadInstruction(Inst); if (NextInst == 0) // Next instruction deleted. BBI = BB.begin(); @@ -202,11 +268,11 @@ bool DSE::handleFreeWithNonTrivialDependency(Instruction *F, MemDepResult Dep) { AliasAnalysis &AA = getAnalysis(); - StoreInst *Dependency = dyn_cast_or_null(Dep.getInst()); - if (!Dependency || Dependency->isVolatile()) + Instruction *Dependency = Dep.getInst(); + if (!Dependency || !doesClobberMemory(Dependency) || !isElidable(Dependency)) return false; - Value *DepPointer = Dependency->getPointerOperand()->getUnderlyingObject(); + Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject(); // Check for aliasing. if (AA.alias(F->getOperand(1), 1, DepPointer, 1) != @@ -251,39 +317,28 @@ --BBI; // If we find a store whose pointer is dead. - if (StoreInst* S = dyn_cast(BBI)) { - if (!S->isVolatile()) { + if (doesClobberMemory(BBI)) { + if (isElidable(BBI)) { // See through pointer-to-pointer bitcasts - Value* pointerOperand = S->getPointerOperand()->getUnderlyingObject(); + Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject(); // Alloca'd pointers or byval arguments (which are functionally like // alloca's) are valid candidates for removal. if (deadPointers.count(pointerOperand)) { // DCE instructions only used to calculate that store. + Instruction *Dead = BBI; BBI++; - DeleteDeadInstruction(S, &deadPointers); + DeleteDeadInstruction(Dead, &deadPointers); NumFastStores++; MadeChange = true; + continue; } } - continue; - } - - // We can also remove memcpy's to local variables at the end of a function. - if (MemCpyInst *M = dyn_cast(BBI)) { - Value *dest = M->getDest()->getUnderlyingObject(); - - if (deadPointers.count(dest)) { - BBI++; - DeleteDeadInstruction(M, &deadPointers); - NumFastOther++; - MadeChange = true; + // Because a memcpy or memmove is also a load, we can't skip it if we + // didn't remove it. + if (!isa(BBI)) continue; - } - - // Because a memcpy is also a load, we can't skip it if we didn't remove - // it. } Value* killPointer = 0; @@ -304,11 +359,11 @@ killPointer = L->getPointerOperand(); } else if (VAArgInst* V = dyn_cast(BBI)) { killPointer = V->getOperand(0); - } else if (isa(BBI) && - isa(cast(BBI)->getLength())) { - killPointer = cast(BBI)->getSource(); + } else if (isa(BBI) && + isa(cast(BBI)->getLength())) { + killPointer = cast(BBI)->getSource(); killPointerSize = cast( - cast(BBI)->getLength())->getZExtValue(); + cast(BBI)->getLength())->getZExtValue(); } else if (AllocaInst* A = dyn_cast(BBI)) { deadPointers.erase(A); Added: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll?rev=86667&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll Tue Nov 10 00:46:40 2009 @@ -0,0 +1,19 @@ +; RUN: opt -S -dse < %s | FileCheck %s + +declare void @llvm.lifetime.end(i64, i8*) +declare void @llvm.memset.i8(i8*, i8, i8, i32) + +define void @test1() { +; CHECK: @test1 + %A = alloca i8 + + store i8 0, i8* %A ;; Written to by memset + call void @llvm.lifetime.end(i64 1, i8* %A) +; CHECK: lifetime.end + + call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) +; CHECK-NOT: memset + + ret void +; CHECK: ret void +} Added: llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll?rev=86667&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Tue Nov 10 00:46:40 2009 @@ -0,0 +1,47 @@ +; RUN: opt -S -dse < %s | FileCheck %s + +declare void @llvm.memcpy.i8(i8*, i8*, i8, i32) +declare void @llvm.memmove.i8(i8*, i8*, i8, i32) +declare void @llvm.memset.i8(i8*, i8, i8, i32) + +define void @test1() { +; CHECK: @test1 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memcpy +; CHECK-NOT: store + + call void @llvm.memcpy.i8(i8* %A, i8* %B, i8 -1, i32 0) + + ret void +; CHECK: ret void +} + +define void @test2() { +; CHECK: @test2 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memmove +; CHECK-NOT: store + + call void @llvm.memmove.i8(i8* %A, i8* %B, i8 -1, i32 0) + + ret void +; CHECK: ret void +} + +define void @test3() { +; CHECK: @test3 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memset +; CHECK-NOT: store + + call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) + + ret void +; CHECK: ret void +} Added: llvm/trunk/test/Transforms/DeadStoreElimination/partial-overwrite.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/partial-overwrite.ll?rev=86667&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/partial-overwrite.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/partial-overwrite.ll Tue Nov 10 00:46:40 2009 @@ -0,0 +1,14 @@ +; RUN: opt -dse -S %s | FileCheck %s +; Note that we could do better by merging the two stores into one. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @test(i32* %P) { + store i32 0, i32* %P +; CHECK: store i32 + %Q = bitcast i32* %P to i16* + store i16 1, i16* %Q +; CHECK: store i16 + ret void +} From nicholas at mxc.ca Tue Nov 10 01:00:44 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 10 Nov 2009 07:00:44 -0000 Subject: [llvm-commits] [llvm] r86668 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200911100700.nAA70iQi022203@zion.cs.uiuc.edu> Author: nicholas Date: Tue Nov 10 01:00:43 2009 New Revision: 86668 URL: http://llvm.org/viewvc/llvm-project?rev=86668&view=rev Log: Simplify. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86668&r1=86667&r2=86668&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 10 01:00:43 2009 @@ -121,9 +121,7 @@ assert(doesClobberMemory(I)); if (StoreInst *SI = dyn_cast(I)) { if (!TD) return -1u; - const PointerType *PTy = - cast(SI->getPointerOperand()->getType()); - return TD->getTypeStoreSize(PTy->getElementType()); + return TD->getTypeStoreSize(SI->getOperand(0)->getType()); } Value *Len; From sabre at nondot.org Tue Nov 10 01:23:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 07:23:37 -0000 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll Message-ID: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 01:23:37 2009 New Revision: 86670 URL: http://llvm.org/viewvc/llvm-project?rev=86670&view=rev Log: unify the code that determines whether it is a good idea to change the type of a computation. This fixes some infinite loops when dealing with TD that has no native types. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll llvm/trunk/test/Transforms/InstCombine/cast.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86670&r1=86669&r2=86670&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 10 01:23:37 2009 @@ -477,6 +477,34 @@ return Ty; } +/// ShouldChangeType - Return true if it is desirable to convert a computation +/// from 'From' to 'To'. We don't want to convert from a legal to an illegal +/// type for example, or from a smaller to a larger illegal type. +static bool ShouldChangeType(const Type *From, const Type *To, + const TargetData *TD) { + assert(isa(From) && isa(To)); + + // If we don't have TD, we don't know if the source/dest are legal. + if (!TD) return false; + + unsigned FromWidth = From->getPrimitiveSizeInBits(); + unsigned ToWidth = To->getPrimitiveSizeInBits(); + bool FromLegal = TD->isLegalInteger(FromWidth); + bool ToLegal = TD->isLegalInteger(ToWidth); + + // If this is a legal integer from type, and the result would be an illegal + // type, don't do the transformation. + if (FromLegal && !ToLegal) + return false; + + // Otherwise, if both are illegal, do not increase the size of the result. We + // do allow things like i160 -> i64, but not i64 -> i160. + if (!FromLegal && !ToLegal && ToWidth > FromWidth) + return false; + + return true; +} + /// getBitCastOperand - If the specified operand is a CastInst, a constant /// expression bitcast, or a GetElementPtrInst with all zero indices, return the /// operand value, otherwise return null. @@ -8082,11 +8110,9 @@ // it is currently legal. if (!isa(Src->getType()) || !isa(CI.getType()) || - (TD && TD->isLegalInteger(CI.getType()->getPrimitiveSizeInBits())) || - (TD && !TD->isLegalInteger(Src->getType()->getPrimitiveSizeInBits()))) + ShouldChangeType(CI.getType(), Src->getType(), TD)) if (Instruction *NV = FoldOpIntoPhi(CI)) return NV; - } return 0; @@ -8235,10 +8261,8 @@ // Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - if (TD && - (TD->isLegalInteger(DestTy->getScalarType()->getPrimitiveSizeInBits()) || - !TD->isLegalInteger((SrcI->getType()->getScalarType() - ->getPrimitiveSizeInBits()))) && + if (!isa(SrcI->getType()) || + ShouldChangeType(SrcI->getType(), DestTy, TD) && CanEvaluateInDifferentType(SrcI, DestTy, CI.getOpcode(), NumCastsRemoved)) { // If this cast is a truncate, evaluting in a different type always @@ -10784,9 +10808,10 @@ } -// FoldPHIArgOpIntoPHI - If all operands to a PHI node are the same "unary" -// operator and they all are only used by the PHI, PHI together their -// inputs, and do the operation once, to the result of the PHI. + +/// FoldPHIArgOpIntoPHI - If all operands to a PHI node are the same "unary" +/// operator and they all are only used by the PHI, PHI together their +/// inputs, and do the operation once, to the result of the PHI. Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { Instruction *FirstInst = cast(PN.getIncomingValue(0)); @@ -10808,23 +10833,7 @@ // Be careful about transforming integer PHIs. We don't want to pessimize // the code by turning an i32 into an i1293. if (isa(PN.getType()) && isa(CastSrcTy)) { - // If we don't have TD, we don't know if the original PHI was legal. - if (!TD) return 0; - - unsigned PHIWidth = PN.getType()->getPrimitiveSizeInBits(); - unsigned NewWidth = CastSrcTy->getPrimitiveSizeInBits(); - bool PHILegal = TD->isLegalInteger(PHIWidth); - bool NewLegal = TD->isLegalInteger(NewWidth); - - // If this is a legal integer PHI node, and pulling the operation through - // would cause it to be an illegal integer PHI, don't do the - // transformation. - if (PHILegal && !NewLegal) - return 0; - - // Otherwise, if both are illegal, do not increase the size of the PHI. We - // do allow things like i160 -> i64, but not i64 -> i160. - if (!PHILegal && !NewLegal && NewWidth > PHIWidth) + if (!ShouldChangeType(PN.getType(), CastSrcTy, TD)) return 0; } } else if (isa(FirstInst) || isa(FirstInst)) { Modified: llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll?rev=86670&r1=86669&r2=86670&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll Tue Nov 10 01:23:37 2009 @@ -1,6 +1,6 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32" define i32 @mul(i32 %x, i32 %y) { %A = trunc i32 %x to i8 Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=86670&r1=86669&r2=86670&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Tue Nov 10 01:23:37 2009 @@ -1,6 +1,6 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: opt < %s -instcombine -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64" @inbuf = external global [32832 x i8] ; <[32832 x i8]*> [#uses=1] From sabre at nondot.org Tue Nov 10 01:44:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 07:44:36 -0000 Subject: [llvm-commits] [llvm] r86672 - /llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Message-ID: <200911100744.nAA7ibJ1023609@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 01:44:36 2009 New Revision: 86672 URL: http://llvm.org/viewvc/llvm-project?rev=86672&view=rev Log: optimize test Modified: llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Modified: llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll?rev=86672&r1=86671&r2=86672&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Tue Nov 10 01:44:36 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg | llvm-dis +; RUN: opt < %s -simplifycfg -S ; PR3016 ; Dead use caused invariant violation. From vhernandez at apple.com Tue Nov 10 02:28:36 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 10 Nov 2009 08:28:36 -0000 Subject: [llvm-commits] [llvm] r86675 - in /llvm/trunk: include/llvm/Analysis/ValueTracking.h lib/Analysis/ValueTracking.cpp Message-ID: <200911100828.nAA8Safm025512@zion.cs.uiuc.edu> Author: hernande Date: Tue Nov 10 02:28:35 2009 New Revision: 86675 URL: http://llvm.org/viewvc/llvm-project?rev=86675&view=rev Log: Add ComputeMultiple() analysis function that recursively determines if a Value V is a multiple of unsigned Base Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=86675&r1=86674&r2=86675&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original) +++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Tue Nov 10 02:28:35 2009 @@ -63,6 +63,15 @@ unsigned ComputeNumSignBits(Value *Op, const TargetData *TD = 0, unsigned Depth = 0); + /// ComputeMultiple - This function computes the integer multiple of Base that + /// equals V. If successful, it returns true and returns the multiple in + /// Multiple. If unsuccessful, it returns false. Also, if V can be + /// simplified to an integer, then the simplified V is returned in Val. Look + /// through sext only if LookThroughSExt=true. + bool ComputeMultiple(Value *V, unsigned Base, Value *&Multiple, APInt &Val, + bool LookThroughSExt = false, const TargetData *TD = 0, + unsigned Depth = 0); + /// CannotBeNegativeZero - Return true if we can prove that the specified FP /// value is never equal to -0.0. /// Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=86675&r1=86674&r2=86675&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Nov 10 02:28:35 2009 @@ -789,6 +789,131 @@ return std::max(FirstAnswer, std::min(TyBits, Mask.countLeadingZeros())); } +/// ComputeMultiple - This function computes the integer multiple of Base that +/// equals V. If successful, it returns true and returns the multiple in +/// Multiple. If unsuccessful, it returns false. Also, if V can be +/// simplified to an integer, then the simplified V is returned in Val. It looks +/// through SExt instructions only if LookThroughSExt is true. +bool llvm::ComputeMultiple(Value *V, unsigned Base, Value *&Multiple, + APInt &Val, bool LookThroughSExt, + const TargetData *TD, unsigned Depth) { + const unsigned MaxDepth = 6; + + assert(TD && V && "No Value?"); + assert(Depth <= MaxDepth && "Limit Search Depth"); + assert(V->getType()->isInteger() && "Not integer or pointer type!"); + + const Type *T = V->getType(); + unsigned TSize = TD->getTypeSizeInBits(T->getScalarType()); + + ConstantInt *CI = NULL; + if ((CI = dyn_cast(V))) + Val = CI->getValue(); + + if (Base == 0) + return false; + + if (Base == 1) { + Multiple = V; + return true; + } + + ConstantExpr *CO = dyn_cast(V); + Constant *BaseVal = ConstantInt::get(T, Base); + if (CO && CO == BaseVal) { + // Multiple is 1. + Multiple = ConstantInt::get(T, 1); + return true; + } + + if (CI && CI->getZExtValue() % Base == 0) { + Multiple = ConstantInt::get(T, CI->getZExtValue() / Base); + return true; + } + + if (Depth == MaxDepth) return false; // Limit search depth. + + Operator *I = dyn_cast(V); + if (!I) return false; + + switch (I->getOpcode()) { + default: break; + case Instruction::SExt: { + if (!LookThroughSExt) return false; + // otherwise fall through to ZExt + } + case Instruction::ZExt: { + return ComputeMultiple(I->getOperand(0), Base, Multiple, Val, + LookThroughSExt, TD, Depth+1); + } + case Instruction::Shl: + case Instruction::Mul: { + Value *Op0 = I->getOperand(0); + Value *Op1 = I->getOperand(1); + + if (I->getOpcode() == Instruction::Shl) { + ConstantInt *Op1CI = dyn_cast(Op1); + if (!Op1CI) return false; + // Turn Op0 << Op1 into Op0 * 2^Op1 + APInt Op1Int = Op1CI->getValue(); + uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); + Op1 = ConstantInt::get(V->getContext(), + APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); + } + + Value *Mul0 = NULL; + Value *Mul1 = NULL; + APInt Val0(TSize, 0), Val1(TSize, 0); + bool M0 = ComputeMultiple(Op0, Base, Mul0, Val0, + LookThroughSExt, TD, Depth+1); + bool M1 = ComputeMultiple(Op1, Base, Mul1, Val1, + LookThroughSExt, TD, Depth+1); + + if (M0) { + if (isa(Op1) && isa(Mul0)) { + // V == Base * (Mul0 * Op1), so return (Mul0 * Op1) + Multiple = ConstantExpr::getMul(cast(Mul0), + Val1.getBoolValue() ? ConstantInt::get(V->getContext(), Val1): + cast(Op1)); + return true; + } + + if (ConstantInt *Mul0CI = dyn_cast(Mul0)) + if (Mul0CI->getValue() == 1) { + // V == Base * Op1, so return Op1 + Multiple = Op1; + return true; + } + } + + if (M1) { + if (isa(Op0) && isa(Mul1)) { + // V == Base * (Mul1 * Op0), so return (Mul1 * Op0) + Multiple = ConstantExpr::getMul(cast(Mul1), + Val0.getBoolValue() ? ConstantInt::get(V->getContext(), Val0): + cast(Op0)); + return true; + } + + if (ConstantInt *Mul1CI = dyn_cast(Mul1)) + if (Mul1CI->getValue() == 1) { + // V == Base * Op0, so return Op0 + Multiple = Op0; + return true; + } + } + + if (Val0.getBoolValue() && Val1.getBoolValue()) + // Op1*Op2 was simplified, try computing multiple again. + return ComputeMultiple(ConstantInt::get(V->getContext(), Val0 * Val1), + Base, Multiple, Val, LookThroughSExt, TD, Depth+1); + } + } + + // We could not determine if V is a multiple of Base. + return false; +} + /// CannotBeNegativeZero - Return true if we can prove that the specified FP /// value is never equal to -0.0. /// From vhernandez at apple.com Tue Nov 10 02:32:26 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 10 Nov 2009 08:32:26 -0000 Subject: [llvm-commits] [llvm] r86676 - in /llvm/trunk: include/llvm/Analysis/MemoryBuiltins.h lib/Analysis/MemoryBuiltins.cpp lib/Transforms/IPO/GlobalOpt.cpp test/Analysis/PointerTracking/sizes.ll Message-ID: <200911100832.nAA8WRXI025771@zion.cs.uiuc.edu> Author: hernande Date: Tue Nov 10 02:32:25 2009 New Revision: 86676 URL: http://llvm.org/viewvc/llvm-project?rev=86676&view=rev Log: Update computeArraySize() to use ComputeMultiple() to determine the array size associated with a malloc; also extend PerformHeapAllocSRoA() to check if the optimized malloc's arg had its highest bit set, so that it is safe for ComputeMultiple() to look through sext instructions while determining the optimized malloc's array size Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/test/Analysis/PointerTracking/sizes.ll Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=86676&r1=86675&r2=86676&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Tue Nov 10 02:32:25 2009 @@ -44,9 +44,7 @@ /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst *isArrayMalloc(Value *I, const TargetData *TD); -const CallInst *isArrayMalloc(const Value *I, - const TargetData *TD); +const CallInst *isArrayMalloc(const Value *I, const TargetData *TD); /// getMallocType - Returns the PointerType resulting from the malloc call. /// The PointerType depends on the number of bitcast uses of the malloc call: @@ -67,7 +65,8 @@ /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value *getMallocArraySize(CallInst *CI, const TargetData *TD); +Value *getMallocArraySize(CallInst *CI, const TargetData *TD, + bool LookThroughSExt = false); //===----------------------------------------------------------------------===// // free Call Utility Functions. Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=86676&r1=86675&r2=86676&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Tue Nov 10 02:32:25 2009 @@ -16,7 +16,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Module.h" -#include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" using namespace llvm; @@ -87,12 +87,8 @@ : NULL; } -/// isConstantOne - Return true only if val is constant int 1. -static bool isConstantOne(Value *val) { - return isa(val) && cast(val)->isOne(); -} - -static Value *isArrayMallocHelper(const CallInst *CI, const TargetData *TD) { +static Value *computeArraySize(const CallInst *CI, const TargetData *TD, + bool LookThroughSExt = false) { if (!CI) return NULL; @@ -101,97 +97,28 @@ if (!T || !T->isSized() || !TD) return NULL; - Value *MallocArg = CI->getOperand(1); - const Type *ArgType = MallocArg->getType(); - ConstantExpr *CO = dyn_cast(MallocArg); - BinaryOperator *BO = dyn_cast(MallocArg); - - unsigned ElementSizeInt = TD->getTypeAllocSize(T); + unsigned ElementSize = TD->getTypeAllocSize(T); if (const StructType *ST = dyn_cast(T)) - ElementSizeInt = TD->getStructLayout(ST)->getSizeInBytes(); - Constant *ElementSize = ConstantInt::get(ArgType, ElementSizeInt); - - // First, check if CI is a non-array malloc. - if (CO && CO == ElementSize) - // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. - return ConstantInt::get(ArgType, 1); - - // Second, check if CI is an array malloc whose array size can be determined. - if (isConstantOne(ElementSize)) - return MallocArg; - - if (ConstantInt *CInt = dyn_cast(MallocArg)) - if (CInt->getZExtValue() % ElementSizeInt == 0) - return ConstantInt::get(ArgType, CInt->getZExtValue() / ElementSizeInt); - - if (!CO && !BO) - return NULL; - - Value *Op0 = NULL; - Value *Op1 = NULL; - unsigned Opcode = 0; - if (CO && ((CO->getOpcode() == Instruction::Mul) || - (CO->getOpcode() == Instruction::Shl))) { - Op0 = CO->getOperand(0); - Op1 = CO->getOperand(1); - Opcode = CO->getOpcode(); - } - if (BO && ((BO->getOpcode() == Instruction::Mul) || - (BO->getOpcode() == Instruction::Shl))) { - Op0 = BO->getOperand(0); - Op1 = BO->getOperand(1); - Opcode = BO->getOpcode(); - } + ElementSize = TD->getStructLayout(ST)->getSizeInBytes(); - // Determine array size if malloc's argument is the product of a mul or shl. - if (Op0) { - if (Opcode == Instruction::Mul) { - if (Op1 == ElementSize) - // ArraySize * ElementSize - return Op0; - if (Op0 == ElementSize) - // ElementSize * ArraySize - return Op1; - } - if (Opcode == Instruction::Shl) { - ConstantInt *Op1CI = dyn_cast(Op1); - if (!Op1CI) return NULL; - - APInt Op1Int = Op1CI->getValue(); - uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); - Value *Op1Pow = ConstantInt::get(Op1CI->getContext(), - APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); - if (Op0 == ElementSize) - // ArraySize << log2(ElementSize) - return Op1Pow; - if (Op1Pow == ElementSize) - // ElementSize << log2(ArraySize) - return Op0; - } - } + // If malloc calls' arg can be determined to be a multiple of ElementSize, + // return the multiple. Otherwise, return NULL. + Value *MallocArg = CI->getOperand(1); + Value *Multiple = NULL; + APInt Val(TD->getTypeSizeInBits(MallocArg->getType()->getScalarType()), 0); + if (ComputeMultiple(MallocArg, ElementSize, Multiple, + Val, LookThroughSExt, TD)) + return Multiple; - // We could not determine the malloc array size from MallocArg. return NULL; } /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst *llvm::isArrayMalloc(Value *I, const TargetData *TD) { - CallInst *CI = extractMallocCall(I); - Value *ArraySize = isArrayMallocHelper(CI, TD); - - if (ArraySize && - ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) - return CI; - - // CI is a non-array malloc or we can't figure out that it is an array malloc. - return NULL; -} - const CallInst *llvm::isArrayMalloc(const Value *I, const TargetData *TD) { const CallInst *CI = extractMallocCall(I); - Value *ArraySize = isArrayMallocHelper(CI, TD); + Value *ArraySize = computeArraySize(CI, TD); if (ArraySize && ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) @@ -207,7 +134,7 @@ /// 1: PointerType is the bitcast's result type. /// >1: Unique PointerType cannot be determined, return NULL. const PointerType *llvm::getMallocType(const CallInst *CI) { - assert(isMalloc(CI) && "GetMallocType and not malloc call"); + assert(isMalloc(CI) && "getMallocType and not malloc call"); const PointerType *MallocType = NULL; unsigned NumOfBitCastUses = 0; @@ -247,8 +174,10 @@ /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value *llvm::getMallocArraySize(CallInst *CI, const TargetData *TD) { - return isArrayMallocHelper(CI, TD); +Value *llvm::getMallocArraySize(CallInst *CI, const TargetData *TD, + bool LookThroughSExt) { + assert(isMalloc(CI) && "getMallocArraySize and not malloc call"); + return computeArraySize(CI, TD, LookThroughSExt); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86676&r1=86675&r2=86676&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Nov 10 02:32:25 2009 @@ -1321,15 +1321,15 @@ // if (F1) { free(F1); F1 = 0; } // if (F2) { free(F2); F2 = 0; } // } - Value *RunningOr = 0; + // The malloc can also fail if its argument is too large. + Constant *ConstantZero = ConstantInt::get(CI->getOperand(1)->getType(), 0); + Value *RunningOr = new ICmpInst(CI, ICmpInst::ICMP_SLT, CI->getOperand(1), + ConstantZero, "isneg"); for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) { Value *Cond = new ICmpInst(CI, ICmpInst::ICMP_EQ, FieldMallocs[i], Constant::getNullValue(FieldMallocs[i]->getType()), "isnull"); - if (!RunningOr) - RunningOr = Cond; // First seteq - else - RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", CI); + RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", CI); } // Split the basic block at the old malloc. @@ -1490,7 +1490,7 @@ // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. // We cannot optimize the malloc if we cannot determine malloc array size. - if (Value *NElems = getMallocArraySize(CI, TD)) { + if (Value *NElems = getMallocArraySize(CI, TD, true)) { if (ConstantInt *NElements = dyn_cast(NElems)) // Restrict this transformation to only working on small allocations // (2048 bytes currently), as we don't want to introduce a 16M global or @@ -1535,7 +1535,7 @@ extractMallocCallFromBitCast(Malloc) : cast(Malloc); } - GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD), TD); + GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD, true),TD); return true; } } Modified: llvm/trunk/test/Analysis/PointerTracking/sizes.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PointerTracking/sizes.ll?rev=86676&r1=86675&r2=86676&view=diff ============================================================================== --- llvm/trunk/test/Analysis/PointerTracking/sizes.ll (original) +++ llvm/trunk/test/Analysis/PointerTracking/sizes.ll Tue Nov 10 02:32:25 2009 @@ -31,7 +31,6 @@ } declare i32 @bar(i8*) -declare i32 @bar2(i64*) define i32 @foo1(i32 %n) nounwind { entry: @@ -66,11 +65,6 @@ %call = tail call i8* @malloc(i64 %n) ; [#uses=1] ; CHECK: %call = ; CHECK: ==> %n elements, %n bytes allocated - %mallocsize = mul i64 %n, 8 ; [#uses=1] - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] - %call3 = bitcast i8* %malloccall to i64* ; [#uses=1] -; CHECK: %malloccall = -; CHECK: ==> (8 * %n) elements, (8 * %n) bytes allocated %call2 = tail call i8* @calloc(i64 2, i64 4) nounwind ; [#uses=1] ; CHECK: %call2 = ; CHECK: ==> 8 elements, 8 bytes allocated @@ -78,12 +72,10 @@ ; CHECK: %call4 = ; CHECK: ==> 16 elements, 16 bytes allocated %call6 = tail call i32 @bar(i8* %call) nounwind ; [#uses=1] - %call7 = tail call i32 @bar2(i64* %call3) nounwind ; [#uses=1] %call8 = tail call i32 @bar(i8* %call2) nounwind ; [#uses=1] %call10 = tail call i32 @bar(i8* %call4) nounwind ; [#uses=1] %add = add i32 %call8, %call6 ; [#uses=1] - %add10 = add i32 %add, %call7 ; [#uses=1] - %add11 = add i32 %add10, %call10 ; [#uses=1] + %add11 = add i32 %add, %call10 ; [#uses=1] ret i32 %add11 } From baldrick at free.fr Tue Nov 10 02:42:50 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 09:42:50 +0100 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll In-Reply-To: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> References: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> Message-ID: <4AF9278A.6010803@free.fr> Hi Chris, > + // If we don't have TD, we don't know if the source/dest are legal. > + if (!TD) return false; I guess it is reasonable to assume that if the number of bits is not divisible by 8 then it is illegal. That said, would adding this case buy much? Ciao, Duncan. From baldrick at free.fr Tue Nov 10 03:08:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 09:08:11 -0000 Subject: [llvm-commits] [llvm] r86678 - in /llvm/trunk/lib/CodeGen: IntrinsicLowering.cpp SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200911100908.nAA98CZm007894@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 03:08:09 2009 New Revision: 86678 URL: http://llvm.org/viewvc/llvm-project?rev=86678&view=rev Log: Codegen support for the llvm.invariant/lifetime.start/end intrinsics: just throw them away. Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=86678&r1=86677&r2=86678&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Tue Nov 10 03:08:09 2009 @@ -515,6 +515,15 @@ if (CI->getType() != Type::getVoidTy(Context)) CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); break; + case Intrinsic::invariant_start: + case Intrinsic::lifetime_start: + // Discard region information. + CI->replaceAllUsesWith(UndefValue::get(CI->getType())); + break; + case Intrinsic::invariant_end: + case Intrinsic::lifetime_end: + // Discard region information. + break; } assert(CI->use_empty() && Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86678&r1=86677&r2=86678&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Nov 10 03:08:09 2009 @@ -4409,6 +4409,16 @@ return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX); case Intrinsic::atomic_swap: return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP); + + case Intrinsic::invariant_start: + case Intrinsic::lifetime_start: + // Discard region information. + setValue(&I, DAG.getUNDEF(TLI.getPointerTy())); + return 0; + case Intrinsic::invariant_end: + case Intrinsic::lifetime_end: + // Discard region information. + return 0; } } From evan.cheng at apple.com Tue Nov 10 03:27:15 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 01:27:15 -0800 Subject: [llvm-commits] [llvm] r86404 - in /llvm/trunk/lib/Target/ARM: ARMAddressingModes.h ARMISelDAGToDAG.cpp ARMInstrInfo.td AsmPrinter/ARMAsmPrinter.cpp NEONPreAllocPass.cpp In-Reply-To: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> References: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> Message-ID: <90BAE2B3-491D-4D6F-BA26-4A9CD2E54B84@apple.com> On Nov 7, 2009, at 1:25 PM, Jim Grosbach wrote: > > > bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N, > SDValue &Addr, SDValue &Update, > - SDValue &Opc) { > + SDValue &Opc, SDValue &Align) { > Addr = N; > // Default to no writeback. > Update = CurDAG->getRegister(0, MVT::i32); > Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), MVT::i32); > + // Default to no alignment. > + Align = CurDAG->getTargetConstant(0, MVT::i32); > return true; > } Shouldn't we be able to transfer the alignment on the LoadSDNode / StoreSDNode to Align (capped at 64 / 128 for 64-bit / 128-bit memory operations)? Evan > > @@ -1008,8 +1010,8 @@ > SDNode *N = Op.getNode(); > DebugLoc dl = N->getDebugLoc(); > > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc)) > + SDValue MemAddr, MemUpdate, MemOpc, Align; > + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc, Align)) > return NULL; > > SDValue Chain = N->getOperand(0); > @@ -1034,10 +1036,10 @@ > > if (is64BitVector) { > unsigned Opc = DOpcodes[OpcodeIndex]; > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, > Chain }; > std::vector ResTys(NumVecs, VT); > ResTys.push_back(MVT::Other); > - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); > } > > EVT RegVT = GetNEONSubregVT(VT); > @@ -1045,10 +1047,10 @@ > // Quad registers are directly supported for VLD2, > // loading 2 pairs of D regs. > unsigned Opc = QOpcodes0[OpcodeIndex]; > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, > Chain }; > std::vector ResTys(4, VT); > ResTys.push_back(MVT::Other); > - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); > Chain = SDValue(VLd, 4); > > // Combine the even and odd subregs to produce the result. > @@ -1069,14 +1071,15 @@ > > // Load the even subregs. > unsigned Opc = QOpcodes0[OpcodeIndex]; > - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); > + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Align, > Chain }; > + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 5); > Chain = SDValue(VLdA, NumVecs+1); > > // Load the odd subregs. > Opc = QOpcodes1[OpcodeIndex]; > - const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, > MemOpc, Chain }; > - SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); > + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, > MemOpc, > + Align, Chain }; > + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 5); > Chain = SDValue(VLdB, NumVecs+1); > > // Combine the even and odd subregs to produce the result. > @@ -1096,8 +1099,8 @@ > SDNode *N = Op.getNode(); > DebugLoc dl = N->getDebugLoc(); > > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc)) > + SDValue MemAddr, MemUpdate, MemOpc, Align; > + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc, Align)) > return NULL; > > SDValue Chain = N->getOperand(0); > @@ -1124,13 +1127,14 @@ > Ops.push_back(MemAddr); > Ops.push_back(MemUpdate); > Ops.push_back(MemOpc); > + Ops.push_back(Align); > > if (is64BitVector) { > unsigned Opc = DOpcodes[OpcodeIndex]; > for (unsigned Vec = 0; Vec < NumVecs; ++Vec) > Ops.push_back(N->getOperand(Vec+3)); > Ops.push_back(Chain); > - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), > NumVecs+4); > + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), > NumVecs+5); > } > > EVT RegVT = GetNEONSubregVT(VT); > @@ -1145,7 +1149,7 @@ > N->getOperand(Vec > +3))); > } > Ops.push_back(Chain); > - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), > 8); > + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), > 9); > } > > // Otherwise, quad registers are stored with two separate > instructions, > @@ -1161,18 +1165,18 @@ > Ops.push_back(Chain); > unsigned Opc = QOpcodes0[OpcodeIndex]; > SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType > (), > - MVT::Other, Ops.data(), > NumVecs+4); > + MVT::Other, Ops.data(), > NumVecs+5); > Chain = SDValue(VStA, 1); > > // Store the odd subregs. > Ops[0] = SDValue(VStA, 0); // MemAddr > for (unsigned Vec = 0; Vec < NumVecs; ++Vec) > - Ops[Vec+3] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, > RegVT, > + Ops[Vec+4] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, > RegVT, > N->getOperand(Vec+3)); > - Ops[NumVecs+3] = Chain; > + Ops[NumVecs+4] = Chain; > Opc = QOpcodes1[OpcodeIndex]; > SDNode *VStB = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType > (), > - MVT::Other, Ops.data(), > NumVecs+4); > + MVT::Other, Ops.data(), > NumVecs+5); > Chain = SDValue(VStB, 1); > ReplaceUses(SDValue(N, 0), Chain); > return NULL; > @@ -1186,8 +1190,8 @@ > SDNode *N = Op.getNode(); > DebugLoc dl = N->getDebugLoc(); > > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc)) > + SDValue MemAddr, MemUpdate, MemOpc, Align; > + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc, Align)) > return NULL; > > SDValue Chain = N->getOperand(0); > @@ -1224,6 +1228,7 @@ > Ops.push_back(MemAddr); > Ops.push_back(MemUpdate); > Ops.push_back(MemOpc); > + Ops.push_back(Align); > > unsigned Opc = 0; > if (is64BitVector) { > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=86404&r1=86403&r2=86404&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sat Nov 7 15:25:39 2009 > @@ -340,9 +340,9 @@ > // addrmode6 := reg with optional writeback > // > def addrmode6 : Operand, > - ComplexPattern { > + ComplexPattern { > let PrintMethod = "printAddrMode6Operand"; > - let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm); > + let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm); > } > > // addrmodepc := pc + reg > > Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=86404&r1=86403&r2=86404&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) > +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Nov > 7 15:25:39 2009 > @@ -638,9 +638,17 @@ > const MachineOperand &MO1 = MI->getOperand(Op); > const MachineOperand &MO2 = MI->getOperand(Op+1); > const MachineOperand &MO3 = MI->getOperand(Op+2); > + const MachineOperand &MO4 = MI->getOperand(Op+3); > > - // FIXME: No support yet for specifying alignment. > - O << "[" << getRegisterName(MO1.getReg()) << "]"; > + O << "[" << getRegisterName(MO1.getReg()); > + if (MO4.getImm()) { > + if (Subtarget->isTargetDarwin()) > + O << ", :"; > + else > + O << " @"; > + O << MO4.getImm(); > + } > + O << "]"; > > if (ARM_AM::getAM6WBFlag(MO3.getImm())) { > if (MO2.getReg() == 0) > > Modified: llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp?rev=86404&r1=86403&r2=86404&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp (original) > +++ llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Sat Nov 7 > 15:25:39 2009 > @@ -177,20 +177,20 @@ > case ARM::VST2LNd8: > case ARM::VST2LNd16: > case ARM::VST2LNd32: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 2; > return true; > > case ARM::VST2q8: > case ARM::VST2q16: > case ARM::VST2q32: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 4; > return true; > > case ARM::VST2LNq16a: > case ARM::VST2LNq32a: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 2; > Offset = 0; > Stride = 2; > @@ -198,7 +198,7 @@ > > case ARM::VST2LNq16b: > case ARM::VST2LNq32b: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 2; > Offset = 1; > Stride = 2; > @@ -211,14 +211,14 @@ > case ARM::VST3LNd8: > case ARM::VST3LNd16: > case ARM::VST3LNd32: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 3; > return true; > > case ARM::VST3q8a: > case ARM::VST3q16a: > case ARM::VST3q32a: > - FirstOpnd = 4; > + FirstOpnd = 5; > NumRegs = 3; > Offset = 0; > Stride = 2; > @@ -227,7 +227,7 @@ > case ARM::VST3q8b: > case ARM::VST3q16b: > case ARM::VST3q32b: > - FirstOpnd = 4; > + FirstOpnd = 5; > NumRegs = 3; > Offset = 1; > Stride = 2; > @@ -235,7 +235,7 @@ > > case ARM::VST3LNq16a: > case ARM::VST3LNq32a: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 3; > Offset = 0; > Stride = 2; > @@ -243,7 +243,7 @@ > > case ARM::VST3LNq16b: > case ARM::VST3LNq32b: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 3; > Offset = 1; > Stride = 2; > @@ -256,14 +256,14 @@ > case ARM::VST4LNd8: > case ARM::VST4LNd16: > case ARM::VST4LNd32: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 4; > return true; > > case ARM::VST4q8a: > case ARM::VST4q16a: > case ARM::VST4q32a: > - FirstOpnd = 4; > + FirstOpnd = 5; > NumRegs = 4; > Offset = 0; > Stride = 2; > @@ -272,7 +272,7 @@ > case ARM::VST4q8b: > case ARM::VST4q16b: > case ARM::VST4q32b: > - FirstOpnd = 4; > + FirstOpnd = 5; > NumRegs = 4; > Offset = 1; > Stride = 2; > @@ -280,7 +280,7 @@ > > case ARM::VST4LNq16a: > case ARM::VST4LNq32a: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 4; > Offset = 0; > Stride = 2; > @@ -288,7 +288,7 @@ > > case ARM::VST4LNq16b: > case ARM::VST4LNq32b: > - FirstOpnd = 3; > + FirstOpnd = 4; > NumRegs = 4; > Offset = 1; > Stride = 2; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Tue Nov 10 03:32:10 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 09:32:10 -0000 Subject: [llvm-commits] [llvm] r86681 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911100932.nAA9WBrd009117@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 03:32:10 2009 New Revision: 86681 URL: http://llvm.org/viewvc/llvm-project?rev=86681&view=rev Log: Add brackets to make gcc-4.4 happy. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86681&r1=86680&r2=86681&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 10 03:32:10 2009 @@ -8262,9 +8262,9 @@ // expression tree to something weird like i93 unless the source is also // strange. if (!isa(SrcI->getType()) || - ShouldChangeType(SrcI->getType(), DestTy, TD) && - CanEvaluateInDifferentType(SrcI, DestTy, - CI.getOpcode(), NumCastsRemoved)) { + (ShouldChangeType(SrcI->getType(), DestTy, TD) && + CanEvaluateInDifferentType(SrcI, DestTy, + CI.getOpcode(), NumCastsRemoved))) { // If this cast is a truncate, evaluting in a different type always // eliminates the cast, so it is always a win. If this is a zero-extension, // we need to do an AND to maintain the clear top-part of the computation, From baldrick at free.fr Tue Nov 10 04:25:00 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 10:25:00 -0000 Subject: [llvm-commits] [dragonegg] r86682 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200911101025.nAAAP1HS011382@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 04:24:57 2009 New Revision: 86682 URL: http://llvm.org/viewvc/llvm-project?rev=86682&view=rev Log: It is important for Ada to get rid of trampolines wherever possible. Unfortunately the optimizers have a hard time doing this. Help them out by using llvm.invariant.start to mark the trampoline storage as being constant after the initial write. The llvm.invariant.start/end intrinsics are annoyingly hard to use. There needs to be an llvm.invariant.end call because otherwise the llvm.invariant.start call will be deleted being readonly. The call to llvm.invariant.start needs to dominate the end call, which is hard to achieve cheaply unless the start call is in the entry block. This is the reason this patch pushes the trampoline initialization into the entry block. The region lasts until the end of the function, which means calling llvm.invariant.end at every possible exit point of the program. This is impossible in general, since potentially the optimizers may discover that some call in the program does not return, at which point they may discard vast amounts of unreachable code which might include any llvm.invariant.end calls, at which point the start calls will be deleted too being readonly with no uses. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=86682&r1=86681&r2=86682&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Nov 10 04:24:57 2009 @@ -763,6 +763,26 @@ typedef SmallVector, 8> TreeVector; typedef SmallVector, 8> ValueVector; +/// EndInvariantRegions - Output a call to llvm.invariant.end for each call +/// to llvm.invariant.start recorded in InvariantRegions. +void TreeToLLVM::EndInvariantRegions() { + if (InvariantRegions.empty()) + return; + + Value *Ops[3]; + Value *IEnd = Intrinsic::getDeclaration(TheModule,Intrinsic::invariant_end); + for (unsigned i = 0, e = InvariantRegions.size(); i < e; ++i) { + CallInst *CI = InvariantRegions[i]; + Ops[0] = CI; + Ops[1] = CI->getOperand(1); + Ops[2] = CI->getOperand(2); + Builder.CreateCall(IEnd, Ops, Ops + 3); + } + + // Do not clear out InvariantRegions in case the function has multiple exits: + // we need to output calls to llvm.invariant.end before each one. +} + /// PopulatePhiNodes - Populate generated phi nodes with their operands. void TreeToLLVM::PopulatePhiNodes() { PredVector Predecessors; @@ -929,6 +949,9 @@ TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder); TheDebugInfo->EmitFunctionEnd(Builder.GetInsertBlock(), true); } + + EndInvariantRegions(); + if (RetVals.empty()) Builder.CreateRetVoid(); else if (RetVals.size() == 1 && RetVals[0]->getType() == Fn->getReturnType()){ @@ -2105,6 +2128,7 @@ if (UnwindBB) { CreateExceptionValues(); EmitBlock(UnwindBB); + EndInvariantRegions(); abort();//FIXME //FIXME // Fetch and store exception handler. //FIXME Value *Arg = Builder.CreateLoad(ExceptionValue, "eh_ptr"); @@ -2543,6 +2567,7 @@ // after the function to prevent LLVM from thinking that control flow will // fall into the subsequent block. if (gimple_call_flags(stmt) & ECF_NORETURN) { + EndInvariantRegions(); Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); } @@ -4613,6 +4638,7 @@ case BUILT_IN_TRAP: Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::trap)); // Emit an explicit unreachable instruction. + EndInvariantRegions(); Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); return true; @@ -5459,6 +5485,7 @@ Args.push_back(Handler); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, IID), Args.begin(), Args.end()); + EndInvariantRegions(); Result = Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); @@ -5672,6 +5699,26 @@ // is called. static const Type *VPTy = Type::getInt8PtrTy(Context); + // In order to simplify the use of llvm.invariant.start/end, generate the + // trampoline initialization code in the entry block. + BasicBlock *EntryBlock = Fn->begin(); + + // Note the current builder position. + BasicBlock *SavedInsertBB = Builder.GetInsertBlock(); + BasicBlock::iterator SavedInsertPoint = Builder.GetInsertPoint(); + + // Pop the entry block terminator. There may not be a terminator if the entry + // block was not yet finished. + Instruction *Terminator = EntryBlock->getTerminator(); + assert(((SavedInsertBB != EntryBlock && Terminator) || + (SavedInsertPoint == EntryBlock->end() && !Terminator)) && + "Insertion point doesn't make sense!"); + if (Terminator) + Terminator->removeFromParent(); + + // Point the builder at the end of the entry block. + Builder.SetInsertPoint(EntryBlock); + // Create a stack temporary to hold the trampoline machine code. const Type *TrampType = ArrayType::get(Type::getInt8Ty(Context), TRAMPOLINE_SIZE); @@ -5703,6 +5750,22 @@ unsigned Align = TYPE_ALIGN(TREE_TYPE(TREE_TYPE(gimple_call_arg(stmt, 0))))/8; Store->setAlignment(Align); + // The GCC trampoline storage is constant from this point on. Tell this to + // the optimizers. + Intr = Intrinsic::getDeclaration(TheModule, Intrinsic::invariant_start); + Ops[0] = ConstantInt::get(Type::getInt64Ty(Context), TRAMPOLINE_SIZE); + Ops[1] = Builder.CreateBitCast(Tramp, VPTy); + CallInst *InvStart = Builder.CreateCall(Intr, Ops, Ops + 2); + InvariantRegions.push_back(InvStart); + + // Restore the entry block terminator. + if (Terminator) + EntryBlock->getInstList().push_back(Terminator); + + // Restore the builder insertion point. + if (SavedInsertBB != EntryBlock) + Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); + return true; } Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=86682&r1=86681&r2=86682&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Nov 10 04:24:57 2009 @@ -357,6 +357,10 @@ /// LocalDecls - Map from local declarations to their associated LLVM values. DenseMap > LocalDecls; + /// InvariantRegions - Calls to llvm.invariant.start for which a corresponding + /// call to llvm.invariant.end needs to be generated at function exit points. + SmallVector InvariantRegions; + /// PendingPhis - Phi nodes which have not yet been populated with operands. SmallVector PendingPhis; @@ -469,11 +473,15 @@ /// StartFunctionBody - Start the emission of 'fndecl', outputing all /// declarations for parameters and setting things up. void StartFunctionBody(); - + /// FinishFunctionBody - Once the body of the function has been emitted, this /// cleans up and returns the result function. Function *FinishFunctionBody(); + /// EndInvariantRegions - Output a call to llvm.invariant.end for each call + /// of llvm.invariant.start recorded in InvariantRegions. + void EndInvariantRegions(); + /// PopulatePhiNodes - Populate generated phi nodes with their operands. void PopulatePhiNodes(); From baldrick at free.fr Tue Nov 10 07:49:51 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 13:49:51 -0000 Subject: [llvm-commits] [llvm] r86683 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll Message-ID: <200911101349.nAADnp5u018505@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 07:49:50 2009 New Revision: 86683 URL: http://llvm.org/viewvc/llvm-project?rev=86683&view=rev Log: Teach DSE to eliminate useless trampolines. Added: llvm/trunk/test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86683&r1=86682&r2=86683&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 10 07:49:50 2009 @@ -87,13 +87,13 @@ switch (II->getIntrinsicID()) { default: return false; case Intrinsic::memset: case Intrinsic::memmove: case Intrinsic::memcpy: - case Intrinsic::lifetime_end: return true; + case Intrinsic::init_trampoline: case Intrinsic::lifetime_end: return true; } } return false; } -/// isElidable - If the memory this instruction and the memory it writes to is +/// isElidable - If the value of this instruction and the memory it writes to is /// unused, may we delete this instrtction? static bool isElidable(Instruction *I) { assert(doesClobberMemory(I)); @@ -111,8 +111,15 @@ return SI->getPointerOperand(); if (MemIntrinsic *MI = dyn_cast(I)) return MI->getOperand(1); - assert(cast(I)->getIntrinsicID() == Intrinsic::lifetime_end); - return cast(I)->getOperand(2); + IntrinsicInst *II = cast(I); + switch (II->getIntrinsicID()) { + default: + assert(false && "Unexpected intrinsic!"); + case Intrinsic::init_trampoline: + return II->getOperand(1); + case Intrinsic::lifetime_end: + return II->getOperand(2); + } } /// getStoreSize - Return the length in bytes of the write by the clobbering @@ -129,8 +136,14 @@ Len = MI->getLength(); } else { IntrinsicInst *II = cast(I); - assert(II->getIntrinsicID() == Intrinsic::lifetime_end); - Len = II->getOperand(0); + switch (II->getIntrinsicID()) { + default: + assert(false && "Unexpected intrinsic!"); + case Intrinsic::init_trampoline: + return -1u; + case Intrinsic::lifetime_end: + Len = II->getOperand(0); + } } if (ConstantInt *LenCI = dyn_cast(Len)) if (!LenCI->isAllOnesValue()) Added: llvm/trunk/test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll?rev=86683&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/2009-11-10-Trampoline.ll Tue Nov 10 07:49:50 2009 @@ -0,0 +1,16 @@ +; RUN: opt -S -dse < %s | FileCheck %s + +declare i8* @llvm.init.trampoline(i8*, i8*, i8*) + +declare void @f() + +define void @unused_trampoline() { +; CHECK: @unused_trampoline + %storage = alloca [10 x i8], align 16 ; <[10 x i8]*> [#uses=1] +; CHECK-NOT: alloca + %cast = getelementptr [10 x i8]* %storage, i32 0, i32 0 ; [#uses=1] + %tramp = call i8* @llvm.init.trampoline( i8* %cast, i8* bitcast (void ()* @f to i8*), i8* null ) ; [#uses=1] +; CHECK-NOT: trampoline + ret void +; CHECK: ret void +} From dgregor at apple.com Tue Nov 10 09:30:33 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 10 Nov 2009 15:30:33 -0000 Subject: [llvm-commits] [llvm] r86684 - /llvm/trunk/cmake/modules/AddLLVM.cmake Message-ID: <200911101530.nAAFUY57021601@zion.cs.uiuc.edu> Author: dgregor Date: Tue Nov 10 09:30:33 2009 New Revision: 86684 URL: http://llvm.org/viewvc/llvm-project?rev=86684&view=rev Log: CMake: Add Darwin-specific linker flags for building loadable modules Modified: llvm/trunk/cmake/modules/AddLLVM.cmake Modified: llvm/trunk/cmake/modules/AddLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=86684&r1=86683&r2=86684&view=diff ============================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake (original) +++ llvm/trunk/cmake/modules/AddLLVM.cmake Tue Nov 10 09:30:33 2009 @@ -27,10 +27,16 @@ message(STATUS "Loadable modules not supported on this platform. ${name} ignored.") else() - set(BUILD_SHARED_LIBS ON) llvm_process_sources( ALL_FILES ${ARGN} ) add_library( ${name} MODULE ${ALL_FILES} ) set_target_properties( ${name} PROPERTIES PREFIX "" ) + + if (APPLE) + # Darwin-specific linker flags for loadable modules. + set_target_properties(${name} PROPERTIES + LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress") + endif() + install(TARGETS ${name} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) From johnny.chen at apple.com Tue Nov 10 10:52:26 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Nov 2009 08:52:26 -0800 Subject: [llvm-commits] Question on emitLoadStoreInstruction() of ARMCodeEmitter.cpp In-Reply-To: <1098E54E-0B98-4E3F-BE64-25CE8A9883F4@apple.com> References: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> <1098E54E-0B98-4E3F-BE64-25CE8A9883F4@apple.com> Message-ID: <8F65E3F1-9F95-469F-BA31-0D24BDBEB307@apple.com> Hi Evan, Thanks for the reply. But from the emitLoadStoreInstruction() code inspection, it looks like it special-cases for operand 0 to be base_wb and operand 1 to be dst, which is not the correct order. It should have been operand 0 as dst and operand 1 as base_wb? Johnny On Nov 9, 2009, at 10:38 PM, Evan Cheng wrote: > > On Nov 9, 2009, at 5:46 PM, Johnny Chen wrote: > >> >> Hi, >> >> I have a question wrt the following fragment of code: >> >> // Operand 0 of a pre- and post-indexed store is the address base >> // writeback. Skip it. >> bool Skipped = false; >> if (IsPrePost && Form == ARMII::StFrm) { >> ++OpIdx; >> Skipped = true; >> } >> >> // Set first operand >> if (ImplicitRd) >> // Special handling for implicit use (e.g. PC). >> Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd) >> << ARMII::RegRdShift); >> else >> Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; >> >> and from the Record definition of LDRB_POST: >> >> def LDRB_POST { // Instruction InstARM I AI2ldbpo >> field bits<32> Inst = { ?, ?, ?, ?, 0, 1, ?, 0, ?, 1, 0, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? }; >> string Namespace = "ARM"; >> dag OutOperandList = (outs GPR:$dst, GPR:$base_wb); >> dag InOperandList = (ins GPR:$base, am2offset:$offset, pred:$p); >> string AsmString = "ldrb${p} $dst, [$base], $offset"; >> >> it looks like the processing of "address base writeback" should happen after the processing of RegRd, >> if the ordering of OutOperandList followed by InOperandList is to be observed. Is my understanding of >> the ordering of the MachineOperands correct? > > Right. Defs comes first followed by uses. > >> >> If this is the case, then there could be some bug in the codegen which compensates for the incorrect >> ordering/processing of base_writeback/dst? > > No. It's fine. The second operand is base_wb, base will be skipped. > > Evan > >> >> Thanks. >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Tue Nov 10 10:56:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 08:56:24 -0800 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll In-Reply-To: <4AF9278A.6010803@free.fr> References: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> <4AF9278A.6010803@free.fr> Message-ID: On Nov 10, 2009, at 12:42 AM, Duncan Sands wrote: > Hi Chris, > >> + // If we don't have TD, we don't know if the source/dest are >> legal. >> + if (!TD) return false; > > I guess it is reasonable to assume that if the number of bits is not > divisible by 8 then it is illegal. That said, would adding this case > buy much? I'm not sure what you mean. Do you mean in the case when TD is not available? If so, doing any transformation is not safe, because you might be changing away from a legal type and not know it. -Chris From sabre at nondot.org Tue Nov 10 11:00:48 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 17:00:48 -0000 Subject: [llvm-commits] [llvm] r86689 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911101700.nAAH0mUc024708@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 11:00:47 2009 New Revision: 86689 URL: http://llvm.org/viewvc/llvm-project?rev=86689&view=rev Log: clarify logic. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86689&r1=86688&r2=86689&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 10 11:00:47 2009 @@ -8261,10 +8261,10 @@ // Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - if (!isa(SrcI->getType()) || - (ShouldChangeType(SrcI->getType(), DestTy, TD) && - CanEvaluateInDifferentType(SrcI, DestTy, - CI.getOpcode(), NumCastsRemoved))) { + if ((isa(DestTy) || + ShouldChangeType(SrcI->getType(), DestTy, TD)) && + CanEvaluateInDifferentType(SrcI, DestTy, + CI.getOpcode(), NumCastsRemoved)) { // If this cast is a truncate, evaluting in a different type always // eliminates the cast, so it is always a win. If this is a zero-extension, // we need to do an AND to maintain the clear top-part of the computation, From evan.cheng at apple.com Tue Nov 10 11:02:44 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 09:02:44 -0800 Subject: [llvm-commits] Question on emitLoadStoreInstruction() of ARMCodeEmitter.cpp In-Reply-To: <8F65E3F1-9F95-469F-BA31-0D24BDBEB307@apple.com> References: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> <1098E54E-0B98-4E3F-BE64-25CE8A9883F4@apple.com> <8F65E3F1-9F95-469F-BA31-0D24BDBEB307@apple.com> Message-ID: <16971515-6B3C-484C-82A8-9CC4C5B2FC50@apple.com> On Nov 10, 2009, at 8:52 AM, Johnny Chen wrote: > Hi Evan, > > Thanks for the reply. > But from the emitLoadStoreInstruction() code inspection, it looks > like it special-cases for > operand 0 to be base_wb and operand 1 to be dst, which is not the > correct order. > It should have been operand 0 as dst and operand 1 as base_wb? I don't see it. I haven't been able to test the JIT for a long time but this code used to work fine. Is something broken? Evan > > Johnny > > On Nov 9, 2009, at 10:38 PM, Evan Cheng wrote: > >> >> On Nov 9, 2009, at 5:46 PM, Johnny Chen wrote: >> >>> >>> Hi, >>> >>> I have a question wrt the following fragment of code: >>> >>> // Operand 0 of a pre- and post-indexed store is the address base >>> // writeback. Skip it. >>> bool Skipped = false; >>> if (IsPrePost && Form == ARMII::StFrm) { >>> ++OpIdx; >>> Skipped = true; >>> } >>> >>> // Set first operand >>> if (ImplicitRd) >>> // Special handling for implicit use (e.g. PC). >>> Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd) >>> << ARMII::RegRdShift); >>> else >>> Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; >>> >>> and from the Record definition of LDRB_POST: >>> >>> def LDRB_POST { // Instruction InstARM I AI2ldbpo >>> field bits<32> Inst = { ?, ?, ?, ?, 0, 1, ?, 0, ?, 1, 0, >>> 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? }; >>> string Namespace = "ARM"; >>> dag OutOperandList = (outs GPR:$dst, GPR:$base_wb); >>> dag InOperandList = (ins GPR:$base, am2offset:$offset, pred:$p); >>> string AsmString = "ldrb${p} $dst, [$base], $offset"; >>> >>> it looks like the processing of "address base writeback" should >>> happen after the processing of RegRd, >>> if the ordering of OutOperandList followed by InOperandList is to >>> be observed. Is my understanding of >>> the ordering of the MachineOperands correct? >> >> Right. Defs comes first followed by uses. >> >>> >>> If this is the case, then there could be some bug in the codegen >>> which compensates for the incorrect >>> ordering/processing of base_writeback/dst? >> >> No. It's fine. The second operand is base_wb, base will be skipped. >> >> Evan >> >>> >>> Thanks. >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From baldrick at free.fr Tue Nov 10 11:09:44 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 18:09:44 +0100 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll In-Reply-To: References: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> <4AF9278A.6010803@free.fr> Message-ID: <4AF99E58.8050204@free.fr> Chris Lattner wrote: > > On Nov 10, 2009, at 12:42 AM, Duncan Sands wrote: > >> Hi Chris, >> >>> + // If we don't have TD, we don't know if the source/dest are legal. >>> + if (!TD) return false; >> >> I guess it is reasonable to assume that if the number of bits is not >> divisible by 8 then it is illegal. That said, would adding this case >> buy much? > > I'm not sure what you mean. Do you mean in the case when TD is not > available? If so, doing any transformation is not safe, because you > might be changing away from a legal type and not know it. What I'm saying is that we can be pretty sure that i44 is illegal, even if there is no TD. Thus i44 -> i32 could be done even without TD. Ciao, Duncan. From johnny.chen at apple.com Tue Nov 10 11:10:47 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Nov 2009 09:10:47 -0800 Subject: [llvm-commits] Question on emitLoadStoreInstruction() of ARMCodeEmitter.cpp In-Reply-To: <16971515-6B3C-484C-82A8-9CC4C5B2FC50@apple.com> References: <7A82351B-4D89-4F9A-A90F-D546B6F28832@apple.com> <1098E54E-0B98-4E3F-BE64-25CE8A9883F4@apple.com> <8F65E3F1-9F95-469F-BA31-0D24BDBEB307@apple.com> <16971515-6B3C-484C-82A8-9CC4C5B2FC50@apple.com> Message-ID: <3B0B67C8-95EC-4C4D-B3FE-5996155C1710@apple.com> Hi Evan, I think I have been confusing load with store for this message thread. Thanks. On Nov 10, 2009, at 9:02 AM, Evan Cheng wrote: > > On Nov 10, 2009, at 8:52 AM, Johnny Chen wrote: > >> Hi Evan, >> >> Thanks for the reply. >> But from the emitLoadStoreInstruction() code inspection, it looks like it special-cases for >> operand 0 to be base_wb and operand 1 to be dst, which is not the correct order. >> It should have been operand 0 as dst and operand 1 as base_wb? > > I don't see it. I haven't been able to test the JIT for a long time but this code used to work fine. Is something broken? > > Evan > >> >> Johnny >> >> On Nov 9, 2009, at 10:38 PM, Evan Cheng wrote: >> >>> >>> On Nov 9, 2009, at 5:46 PM, Johnny Chen wrote: >>> >>>> >>>> Hi, >>>> >>>> I have a question wrt the following fragment of code: >>>> >>>> // Operand 0 of a pre- and post-indexed store is the address base >>>> // writeback. Skip it. >>>> bool Skipped = false; >>>> if (IsPrePost && Form == ARMII::StFrm) { >>>> ++OpIdx; >>>> Skipped = true; >>>> } >>>> >>>> // Set first operand >>>> if (ImplicitRd) >>>> // Special handling for implicit use (e.g. PC). >>>> Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd) >>>> << ARMII::RegRdShift); >>>> else >>>> Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; >>>> >>>> and from the Record definition of LDRB_POST: >>>> >>>> def LDRB_POST { // Instruction InstARM I AI2ldbpo >>>> field bits<32> Inst = { ?, ?, ?, ?, 0, 1, ?, 0, ?, 1, 0, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? }; >>>> string Namespace = "ARM"; >>>> dag OutOperandList = (outs GPR:$dst, GPR:$base_wb); >>>> dag InOperandList = (ins GPR:$base, am2offset:$offset, pred:$p); >>>> string AsmString = "ldrb${p} $dst, [$base], $offset"; >>>> >>>> it looks like the processing of "address base writeback" should happen after the processing of RegRd, >>>> if the ordering of OutOperandList followed by InOperandList is to be observed. Is my understanding of >>>> the ordering of the MachineOperands correct? >>> >>> Right. Defs comes first followed by uses. >>> >>>> >>>> If this is the case, then there could be some bug in the codegen which compensates for the incorrect >>>> ordering/processing of base_writeback/dst? >>> >>> No. It's fine. The second operand is base_wb, base will be skipped. >>> >>> Evan >>> >>>> >>>> Thanks. >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> > From kennethuil at gmail.com Tue Nov 10 11:15:39 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 10 Nov 2009 11:15:39 -0600 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll In-Reply-To: <4AF99E58.8050204@free.fr> References: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> <4AF9278A.6010803@free.fr> <4AF99E58.8050204@free.fr> Message-ID: <400d33ea0911100915t21977367l67b85b47ba01d01f@mail.gmail.com> On Tue, Nov 10, 2009 at 11:09 AM, Duncan Sands wrote: > Chris Lattner wrote: >> >> On Nov 10, 2009, at 12:42 AM, Duncan Sands wrote: >> >>> Hi Chris, >>> >>>> + ?// If we don't have TD, we don't know if the source/dest are legal. >>>> + ?if (!TD) return false; >>> >>> I guess it is reasonable to assume that if the number of bits is not >>> divisible by 8 then it is illegal. ?That said, would adding this case >>> buy much? >> >> I'm not sure what you mean. ?Do you mean in the case when TD is not >> available? ?If so, doing any transformation is not safe, because you >> might be changing away from a legal type and not know it. > > What I'm saying is that we can be pretty sure that i44 is illegal, even if > there is no TD. ?Thus i44 -> i32 could be done even without TD. but what about i44->i64? Or i44->i128? If you want the transformation to take target specific stuff into account, feed it target data. If you don't, you should only get target independent transformations. You can always run it again with target data in a target-deployment step... From sabre at nondot.org Tue Nov 10 11:31:25 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 09:31:25 -0800 Subject: [llvm-commits] [llvm] r86670 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast.ll In-Reply-To: <4AF99E58.8050204@free.fr> References: <200911100723.nAA7Nc5X022955@zion.cs.uiuc.edu> <4AF9278A.6010803@free.fr> <4AF99E58.8050204@free.fr> Message-ID: On Nov 10, 2009, at 9:09 AM, Duncan Sands wrote: > Chris Lattner wrote: >> On Nov 10, 2009, at 12:42 AM, Duncan Sands wrote: >>> Hi Chris, >>> >>>> + // If we don't have TD, we don't know if the source/dest are >>>> legal. >>>> + if (!TD) return false; >>> >>> I guess it is reasonable to assume that if the number of bits is not >>> divisible by 8 then it is illegal. That said, would adding this >>> case >>> buy much? >> I'm not sure what you mean. Do you mean in the case when TD is not >> available? If so, doing any transformation is not safe, because >> you might be changing away from a legal type and not know it. > > What I'm saying is that we can be pretty sure that i44 is illegal, > even if > there is no TD. Thus i44 -> i32 could be done even without TD. I don't think it's worth it to worry about this. Particularly when dealing with funny sized integers, doing 'safe' obviously profitable transformations only seems prudent. -Chris From daniel at zuster.org Tue Nov 10 12:20:16 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 18:20:16 -0000 Subject: [llvm-commits] [zorg] r86692 - /zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Message-ID: <200911101820.nAAIKGo3027774@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 12:20:15 2009 New Revision: 86692 URL: http://llvm.org/viewvc/llvm-project?rev=86692&view=rev Log: Allow jobs to be specified as a property. Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py?rev=86692&r1=86691&r2=86692&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py (original) +++ zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Tue Nov 10 12:20:15 2009 @@ -84,7 +84,7 @@ # Build llvm (stage 1). f.addStep(WarningCountingShellCommand(name = "compile.llvm.stage1", - command = "nice -n 10 make -j%d" % jobs, + command = WithProperties("nice -n 10 make -j%s" % jobs), haltOnFailure = True, description=["compile", "llvm", @@ -130,7 +130,7 @@ # Build llvm-gcc. f.addStep(WarningCountingShellCommand(name="compile.llvm-gcc.stage1", - command="nice -n 10 make -j%d" % jobs, + command = WithProperties("nice -n 10 make -j%s" % jobs), haltOnFailure=True, description=["compile", "llvm-gcc"], @@ -185,7 +185,7 @@ # Build LLVM (stage 2). f.addStep(WarningCountingShellCommand(name = "compile.llvm.stage2", - command = "nice -n 10 make -j%d" % jobs, + command = WithProperties("nice -n 10 make -j%s" % jobs), haltOnFailure = True, description=["compile", "llvm", @@ -226,7 +226,7 @@ # Build llvm-gcc (stage 2). f.addStep(WarningCountingShellCommand(name="compile.llvm-gcc.stage2", - command="nice -n 10 make -j%d" % jobs, + command=WithProperties("nice -n 10 make -j%s" % jobs), haltOnFailure=True, description=["compile", "llvm-gcc", From daniel at zuster.org Tue Nov 10 12:21:22 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 18:21:22 -0000 Subject: [llvm-commits] [zorg] r86693 - /zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py Message-ID: <200911101821.nAAILMko027833@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 12:21:22 2009 New Revision: 86693 URL: http://llvm.org/viewvc/llvm-project?rev=86693&view=rev Log: Fix bug in InformativeMailNotifier compare routine that ended up comapring a bound method, which led to an infinite loop. Modified: zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py Modified: zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py?rev=86693&r1=86692&r2=86693&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py (original) +++ zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py Tue Nov 10 12:21:22 2009 @@ -10,6 +10,10 @@ compare_attrs = (mail.MailNotifier.compare_attrs + ["num_lines", "only_failure_logs"]) + # Remove customMesg from the compare_attrs, that would lead to + # recursion, and is checked by the class test. + compare_attrs.remove("customMesg") + # FIXME: The customMessage interface is fairly inefficient, switch to # something new when it becomes available. From baldrick at free.fr Tue Nov 10 12:21:37 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 18:21:37 -0000 Subject: [llvm-commits] [llvm] r86694 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200911101821.nAAILbbK027850@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 12:21:37 2009 New Revision: 86694 URL: http://llvm.org/viewvc/llvm-project?rev=86694&view=rev Log: Fix obvious typo. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86694&r1=86693&r2=86694&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 10 12:21:37 2009 @@ -142,7 +142,7 @@ case Intrinsic::init_trampoline: return -1u; case Intrinsic::lifetime_end: - Len = II->getOperand(0); + Len = II->getOperand(1); } } if (ConstantInt *LenCI = dyn_cast(Len)) From daniel at zuster.org Tue Nov 10 12:24:38 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Nov 2009 18:24:38 -0000 Subject: [llvm-commits] [llvm] r86695 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <200911101824.nAAIOcnH027959@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 12:24:37 2009 New Revision: 86695 URL: http://llvm.org/viewvc/llvm-project?rev=86695&view=rev Log: Add a monstrous hack to improve X86ISelDAGToDAG compile time. - Force NDEBUG on in any Release build. This drops the compile time to ~100s from ~600s, in Release mode. - This may just be a temporary workaround, I don't know the true nature of the gcc-4.2 compile time performance problem. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=86695&r1=86694&r2=86695&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Nov 10 12:24:37 2009 @@ -12,6 +12,14 @@ // //===----------------------------------------------------------------------===// +// Force NDEBUG on in any optimized build on Darwin. +// +// FIXME: This is a huge hack, to work around ridiculously awful compile times +// on this file with gcc-4.2 on Darwin, in Release mode. +#if defined(__APPLE__) && defined(__OPTIMIZE__) && !defined(NDEBUG) +#define NDEBUG +#endif + #define DEBUG_TYPE "x86-isel" #include "X86.h" #include "X86InstrBuilder.h" From kennethuil at gmail.com Tue Nov 10 12:32:41 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 10 Nov 2009 12:32:41 -0600 Subject: [llvm-commits] [llvm] r86695 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp In-Reply-To: <200911101824.nAAIOcnH027959@zion.cs.uiuc.edu> References: <200911101824.nAAIOcnH027959@zion.cs.uiuc.edu> Message-ID: <400d33ea0911101032o3157314exc5cc139b0ee8c4e1@mail.gmail.com> On Tue, Nov 10, 2009 at 12:24 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Tue Nov 10 12:24:37 2009 > New Revision: 86695 > > URL: http://llvm.org/viewvc/llvm-project?rev=86695&view=rev > Log: > Add a monstrous hack to improve X86ISelDAGToDAG compile time. > ?- Force NDEBUG on in any Release build. This drops the compile time to ~100s > ? from ~600s, in Release mode. > > ?- This may just be a temporary workaround, I don't know the true nature of the > ? gcc-4.2 compile time performance problem. > > Modified: > ? ?llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > > Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=86695&r1=86694&r2=86695&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Nov 10 12:24:37 2009 > @@ -12,6 +12,14 @@ > ?// > ?//===----------------------------------------------------------------------===// > > +// Force NDEBUG on in any optimized build on Darwin. > +// > +// FIXME: This is a huge hack, to work around ridiculously awful compile times > +// on this file with gcc-4.2 on Darwin, in Release mode. > +#if defined(__APPLE__) && defined(__OPTIMIZE__) && !defined(NDEBUG) > +#define NDEBUG > +#endif > + > ?#define DEBUG_TYPE "x86-isel" > ?#include "X86.h" > ?#include "X86InstrBuilder.h" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > gcc 4.3.2 on Linux x86 and gcc 3.4.4 on cygwin also take an awfully long time to compile that particularly long file. Is there something special about Darwin, or would that hack work safely on other platforms? From kennethuil at gmail.com Tue Nov 10 12:33:51 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 10 Nov 2009 12:33:51 -0600 Subject: [llvm-commits] [llvm] r86695 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp In-Reply-To: <400d33ea0911101033ra54a96dv4062cf8ad72b8353@mail.gmail.com> References: <200911101824.nAAIOcnH027959@zion.cs.uiuc.edu> <400d33ea0911101032o3157314exc5cc139b0ee8c4e1@mail.gmail.com> <400d33ea0911101033ra54a96dv4062cf8ad72b8353@mail.gmail.com> Message-ID: <400d33ea0911101033k786fbfd3ha4fd3c460d8201b3@mail.gmail.com> On Tue, Nov 10, 2009 at 12:33 PM, Kenneth Uildriks wrote: >> gcc 4.3.2 on Linux x86 and gcc 3.4.4 on cygwin also take an awfully >> long time to compile that particularly long file. ?Is there something >> special about Darwin, or would that hack work safely on other >> platforms? >> > > I meant to say, of course, that they take an awfully long time to > compile that particular file. > From grosbach at apple.com Tue Nov 10 13:11:36 2009 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 10 Nov 2009 19:11:36 -0000 Subject: [llvm-commits] [test-suite] r86698 - /test-suite/trunk/Makefile.programs Message-ID: <200911101911.nAAJBbEN029615@zion.cs.uiuc.edu> Author: grosbach Date: Tue Nov 10 13:11:36 2009 New Revision: 86698 URL: http://llvm.org/viewvc/llvm-project?rev=86698&view=rev Log: ARM/Thumb llcbeta Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=86698&r1=86697&r2=86698&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Tue Nov 10 13:11:36 2009 @@ -244,13 +244,11 @@ LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -arm-dynamic-stack-alignment -#-combiner-alias-analysis +LLCBETAOPTION := -combiner-alias-analysis #-schedule-livein-copies endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -arm-dynamic-stack-alignment -#-combiner-alias-analysis +LLCBETAOPTION := -combiner-alias-analysis #-enable-thumb-reg-scavenging endif From vkutuzov at accesssoftek.com Tue Nov 10 13:18:45 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Tue, 10 Nov 2009 11:18:45 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> Message-ID: <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> Is this Ok to submit? Best regards, Viktor ----- Original Message ----- From: "Viktor Kutuzov" To: "Commit Messages and Patches for LLVM" Sent: Thursday, November 05, 2009 4:14 PM Subject: [llvm-commits] [PATCH] LTO code generator options Hello everyone, Please find the patch attached. This patch continues the #85419 - Fix to pass options from Gold plugin to LTO codegen. It lets user to specify the target triple, cpu and specific platform attribute (features) for LTO code generator. The following options has been added (names match the llc option names): -mtriple - to set the target triple; -mcpu - to set the target cpu; -mattr - to set additional platform-specific features; If speciffied, these options override all implicit settting. I have also added the -preserve option to keep all intermediate files in place for debug and troubleshooting purposes and did a little code cleaning around my changes to comply with the LLVM coding style policy. Best regards, Viktor From clattner at apple.com Tue Nov 10 13:26:39 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 10 Nov 2009 11:26:39 -0800 Subject: [llvm-commits] [llvm] r86694 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <200911101821.nAAILbbK027850@zion.cs.uiuc.edu> References: <200911101821.nAAILbbK027850@zion.cs.uiuc.edu> Message-ID: <5841EAC1-CD97-4512-BF44-59AB534401B5@apple.com> On Nov 10, 2009, at 10:21 AM, Duncan Sands wrote: > Author: baldrick > Date: Tue Nov 10 12:21:37 2009 > New Revision: 86694 > > URL: http://llvm.org/viewvc/llvm-project?rev=86694&view=rev > Log: > Fix obvious typo. Can we get a 'break' after it too? :) -Chris > > Modified: > llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86694&r1=86693&r2=86694&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue > Nov 10 12:21:37 2009 > @@ -142,7 +142,7 @@ > case Intrinsic::init_trampoline: > return -1u; > case Intrinsic::lifetime_end: > - Len = II->getOperand(0); > + Len = II->getOperand(1); > } > } > if (ConstantInt *LenCI = dyn_cast(Len)) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Tue Nov 10 13:36:40 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 19:36:40 -0000 Subject: [llvm-commits] [llvm] r86705 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200911101936.nAAJaedH030734@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 10 13:36:40 2009 New Revision: 86705 URL: http://llvm.org/viewvc/llvm-project?rev=86705&view=rev Log: Add defensive break. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86705&r1=86704&r2=86705&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Nov 10 13:36:40 2009 @@ -143,6 +143,7 @@ return -1u; case Intrinsic::lifetime_end: Len = II->getOperand(1); + break; } } if (ConstantInt *LenCI = dyn_cast(Len)) From baldrick at free.fr Tue Nov 10 13:37:08 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 Nov 2009 20:37:08 +0100 Subject: [llvm-commits] [llvm] r86694 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <5841EAC1-CD97-4512-BF44-59AB534401B5@apple.com> References: <200911101821.nAAILbbK027850@zion.cs.uiuc.edu> <5841EAC1-CD97-4512-BF44-59AB534401B5@apple.com> Message-ID: <4AF9C0E4.2010101@free.fr> > Can we get a 'break' after it too? :) Done in revision 86705. Ciao, Duncan. From evan.cheng at apple.com Tue Nov 10 13:44:56 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 19:44:56 -0000 Subject: [llvm-commits] [llvm] r86706 - /llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Message-ID: <200911101944.nAAJivRW031081@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 10 13:44:56 2009 New Revision: 86706 URL: http://llvm.org/viewvc/llvm-project?rev=86706&view=rev Log: Add a comment. Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=86706&r1=86705&r2=86706&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Nov 10 13:44:56 2009 @@ -418,6 +418,8 @@ // Misc. // +// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags +// to APSR. let Defs = [CPSR], Uses = [FPSCR] in def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs", "\tAPSR_nzcv, FPSCR", From evan.cheng at apple.com Tue Nov 10 13:48:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 19:48:13 -0000 Subject: [llvm-commits] [llvm] r86707 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200911101948.nAAJmDLK031197@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 10 13:48:13 2009 New Revision: 86707 URL: http://llvm.org/viewvc/llvm-project?rev=86707&view=rev Log: Change Thumb1 address mode printing, instead of [r0, #2 * 4] Now [r0, #8] This makes Thumb2 assembly more uniform and frankly the scale doesn't add much. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=86707&r1=86706&r2=86707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Nov 10 13:48:13 2009 @@ -715,11 +715,8 @@ O << "[" << getRegisterName(MO1.getReg()); if (MO3.getReg()) O << ", " << getRegisterName(MO3.getReg()); - else if (unsigned ImmOffs = MO2.getImm()) { - O << ", #" << ImmOffs; - if (Scale > 1) - O << " * " << Scale; - } + else if (unsigned ImmOffs = MO2.getImm()) + O << ", #" << ImmOffs * Scale; O << "]"; } From vhernandez at apple.com Tue Nov 10 13:53:28 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 10 Nov 2009 19:53:28 -0000 Subject: [llvm-commits] [llvm] r86712 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200911101953.nAAJrS1R031441@zion.cs.uiuc.edu> Author: hernande Date: Tue Nov 10 13:53:28 2009 New Revision: 86712 URL: http://llvm.org/viewvc/llvm-project?rev=86712&view=rev Log: make this handle redefinition of malloc function with different prototype correctly Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86712&r1=86711&r2=86712&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Nov 10 13:53:28 2009 @@ -494,22 +494,21 @@ BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd; Module* M = BB->getParent()->getParent(); const Type *BPTy = Type::getInt8PtrTy(BB->getContext()); - if (!MallocF) + Value *MallocFunc = MallocF; + if (!MallocFunc) // prototype malloc as "void *malloc(size_t)" - MallocF = cast(M->getOrInsertFunction("malloc", BPTy, - IntPtrTy, NULL)); - if (!MallocF->doesNotAlias(0)) MallocF->setDoesNotAlias(0); + MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL); const PointerType *AllocPtrType = PointerType::getUnqual(AllocTy); CallInst *MCall = NULL; Instruction *Result = NULL; if (InsertBefore) { - MCall = CallInst::Create(MallocF, AllocSize, "malloccall", InsertBefore); + MCall = CallInst::Create(MallocFunc, AllocSize, "malloccall", InsertBefore); Result = MCall; if (Result->getType() != AllocPtrType) // Create a cast instruction to convert to the right type... Result = new BitCastInst(MCall, AllocPtrType, Name, InsertBefore); } else { - MCall = CallInst::Create(MallocF, AllocSize, "malloccall"); + MCall = CallInst::Create(MallocFunc, AllocSize, "malloccall"); Result = MCall; if (Result->getType() != AllocPtrType) { InsertAtEnd->getInstList().push_back(MCall); @@ -518,7 +517,10 @@ } } MCall->setTailCall(); - MCall->setCallingConv(MallocF->getCallingConv()); + if (Function *F = dyn_cast(MallocFunc)) { + MCall->setCallingConv(F->getCallingConv()); + if (!F->doesNotAlias(0)) F->setDoesNotAlias(0); + } assert(MCall->getType() != Type::getVoidTy(BB->getContext()) && "Malloc has void return type"); From vhernandez at apple.com Tue Nov 10 13:54:56 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 10 Nov 2009 11:54:56 -0800 Subject: [llvm-commits] [llvm] r86525 - /llvm/trunk/lib/VMCore/Instructions.cpp In-Reply-To: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> References: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> Message-ID: <745D848F-B85D-4F45-B265-EABAD791A9AC@apple.com> I just realized that this patch only fixed this for CreateFree(), but it also needs to be fixed in CreateMalloc(). Fixed CreateMalloc() in r86712. Victor On Nov 8, 2009, at 11:12 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Nov 9 01:12:01 2009 > New Revision: 86525 > > URL: http://llvm.org/viewvc/llvm-project?rev=86525&view=rev > Log: > make this handle redefinition of malloc with different prototype > correctly. > > Modified: > llvm/trunk/lib/VMCore/Instructions.cpp > > Modified: llvm/trunk/lib/VMCore/Instructions.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86525&r1=86524&r2=86525&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Instructions.cpp (original) > +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Nov 9 01:12:01 2009 > @@ -568,8 +568,7 @@ > const Type *VoidTy = Type::getVoidTy(M->getContext()); > const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); > // prototype free as "void free(void*)" > - Function *FreeFunc = cast(M->getOrInsertFunction > ("free", VoidTy, > - > IntPtrTy, NULL)); > + Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, > IntPtrTy, NULL); > CallInst* Result = NULL; > Value *PtrCast = Source; > if (InsertBefore) { > @@ -582,7 +581,8 @@ > Result = CallInst::Create(FreeFunc, PtrCast, ""); > } > Result->setTailCall(); > - Result->setCallingConv(FreeFunc->getCallingConv()); > + if (Function *F = dyn_cast(FreeFunc)) > + Result->setCallingConv(F->getCallingConv()); > > return Result; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Tue Nov 10 15:02:18 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Nov 2009 21:02:18 -0000 Subject: [llvm-commits] [llvm] r86714 - /llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Message-ID: <200911102102.nAAL2IGK001303@zion.cs.uiuc.edu> Author: djg Date: Tue Nov 10 15:02:18 2009 New Revision: 86714 URL: http://llvm.org/viewvc/llvm-project?rev=86714&view=rev Log: Optimize test more. Modified: llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Modified: llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll?rev=86714&r1=86713&r2=86714&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Tue Nov 10 15:02:18 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -S +; RUN: opt < %s -simplifycfg -disable-output ; PR3016 ; Dead use caused invariant violation. From vkutuzov at accesssoftek.com Tue Nov 10 15:10:55 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Tue, 10 Nov 2009 13:10:55 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options: --verbose References: <6AE1604EE3EC5F4296C096518C6B77EEF99C4FAA@mail.accesssoftek.com> Message-ID: <7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55> Hello everyone, This patch adds --verbose LTO code generator option . It also contains some cosmetic changes in the LTOCodeGenerator.cpp file to follow the LLVM coding standards. Is it Ok to submit? Best regards, Viktor -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-lto-codegen_verbose.diff Type: application/octet-stream Size: 10079 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091110/20fd8f66/attachment.obj From evan.cheng at apple.com Tue Nov 10 15:14:06 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 21:14:06 -0000 Subject: [llvm-commits] [llvm] r86715 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/Transforms/LoopStrengthReduce/count-to-zero.ll Message-ID: <200911102114.nAALE6ZP001781@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 10 15:14:05 2009 New Revision: 86715 URL: http://llvm.org/viewvc/llvm-project?rev=86715&view=rev Log: Generalize lsr code that optimize loop to count down towards zero. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/count-to-zero.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=86715&r1=86714&r2=86715&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Nov 10 15:14:05 2009 @@ -51,6 +51,7 @@ STATISTIC(NumShadow, "Number of Shadow IVs optimized"); STATISTIC(NumImmSunk, "Number of common expr immediates sunk into uses"); STATISTIC(NumLoopCond, "Number of loop terminating conds optimized"); +STATISTIC(NumCountZero, "Number of count iv optimized to count toward zero"); static cl::opt EnableFullLSRMode("enable-full-lsr", cl::init(false), @@ -136,7 +137,8 @@ const SCEV *const * &CondStride); void OptimizeIndvars(Loop *L); - void OptimizeLoopCountIV(Loop *L); + void OptimizeLoopCountIV(const SCEV *Stride, + IVUsersOfOneStride &Uses, Loop *L); void OptimizeLoopTermCond(Loop *L); /// OptimizeShadowIV - If IV is used in a int-to-float cast @@ -1519,8 +1521,8 @@ // have the full access expression to rewrite the use. std::vector UsersToProcess; const SCEV *CommonExprs = CollectIVUsers(Stride, Uses, L, AllUsesAreAddresses, - AllUsesAreOutsideLoop, - UsersToProcess); + AllUsesAreOutsideLoop, + UsersToProcess); // Sort the UsersToProcess array so that users with common bases are // next to each other. @@ -1593,8 +1595,8 @@ Type::getInt32Ty(Preheader->getContext())), 0); - /// Choose a strength-reduction strategy and prepare for it by creating - /// the necessary PHIs and adjusting the bookkeeping. + // Choose a strength-reduction strategy and prepare for it by creating + // the necessary PHIs and adjusting the bookkeeping. if (ShouldUseFullStrengthReductionMode(UsersToProcess, L, AllUsesAreAddresses, Stride)) { PrepareToStrengthReduceFully(UsersToProcess, Stride, CommonExprs, L, @@ -2418,107 +2420,142 @@ ++NumLoopCond; } +/// isUsedByExitBranch - Return true if icmp is used by a loop terminating +/// conditional branch or it's and / or with other conditions before being used +/// as the condition. +static bool isUsedByExitBranch(ICmpInst *Cond, Loop *L) { + BasicBlock *CondBB = Cond->getParent(); + if (!L->isLoopExiting(CondBB)) + return false; + BranchInst *TermBr = dyn_cast(CondBB->getTerminator()); + if (!TermBr->isConditional()) + return false; + + Value *User = *Cond->use_begin(); + Instruction *UserInst = dyn_cast(User); + while (UserInst && + (UserInst->getOpcode() == Instruction::And || + UserInst->getOpcode() == Instruction::Or)) { + if (!UserInst->hasOneUse() || UserInst->getParent() != CondBB) + return false; + User = *User->use_begin(); + UserInst = dyn_cast(User); + } + return User == TermBr; +} + /// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for deciding /// when to exit the loop is used only for that purpose, try to rearrange things -/// so it counts down to a test against zero. -void LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) { - - // If the number of times the loop is executed isn't computable, give up. - const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); - if (isa(BackedgeTakenCount)) +/// so it counts down to a test against zero which tends to be cheaper. +void LoopStrengthReduce::OptimizeLoopCountIV(const SCEV *Stride, + IVUsersOfOneStride &Uses, + Loop *L) { + if (Uses.Users.size() != 1) return; - // Get the terminating condition for the loop if possible (this isn't - // necessarily in the latch, or a block that's a predecessor of the header). - if (!L->getExitBlock()) - return; // More than one loop exit blocks. - - // Okay, there is one exit block. Try to find the condition that causes the - // loop to be exited. - BasicBlock *ExitingBlock = L->getExitingBlock(); - if (!ExitingBlock) - return; // More than one block exiting! - - // Okay, we've computed the exiting block. See what condition causes us to - // exit. - // - // FIXME: we should be able to handle switch instructions (with a single exit) - BranchInst *TermBr = dyn_cast(ExitingBlock->getTerminator()); - if (TermBr == 0) return; - assert(TermBr->isConditional() && "If unconditional, it can't be in loop!"); - if (!isa(TermBr->getCondition())) + // If the only use is an icmp of an loop exiting conditional branch, then + // attempts the optimization. + BasedUser User = BasedUser(*Uses.Users.begin(), SE); + Instruction *Inst = User.Inst; + if (!L->contains(Inst->getParent())) return; - ICmpInst *Cond = cast(TermBr->getCondition()); - // Handle only tests for equality for the moment, and only stride 1. - if (Cond->getPredicate() != CmpInst::ICMP_EQ) + ICmpInst *Cond = dyn_cast(Inst); + if (!Cond) return; - const SCEV *IV = SE->getSCEV(Cond->getOperand(0)); + // Handle only tests for equality for the moment. + if (Cond->getPredicate() != CmpInst::ICMP_EQ || !Cond->hasOneUse()) + return; + if (!isUsedByExitBranch(Cond, L)) + return; + + Value *CondOp0 = Cond->getOperand(0); + const SCEV *IV = SE->getSCEV(CondOp0); const SCEVAddRecExpr *AR = dyn_cast(IV); - const SCEV *One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); - if (!AR || !AR->isAffine() || AR->getStepRecurrence(*SE) != One) + if (!AR || !AR->isAffine()) + return; + + const SCEVConstant *SC = dyn_cast(AR->getStepRecurrence(*SE)); + if (!SC || SC->getValue()->getSExtValue() < 0) + // If it's already counting down, don't do anything. + return; + + // If the RHS of the comparison is not an loop invariant, the rewrite + // cannot be done. Also bail out if it's already comparing against a zero. + Value *RHS = Cond->getOperand(1); + if (!L->isLoopInvariant(RHS) || + (isa(RHS) && cast(RHS)->isZero())) return; - // If the RHS of the comparison is defined inside the loop, the rewrite - // cannot be done. - if (Instruction *CR = dyn_cast(Cond->getOperand(1))) - if (L->contains(CR->getParent())) - return; // Make sure the IV is only used for counting. Value may be preinc or // postinc; 2 uses in either case. - if (!Cond->getOperand(0)->hasNUses(2)) + if (!CondOp0->hasNUses(2)) return; - PHINode *phi = dyn_cast(Cond->getOperand(0)); - Instruction *incr; - if (phi && phi->getParent()==L->getHeader()) { - // value tested is preinc. Find the increment. - // A CmpInst is not a BinaryOperator; we depend on this. - Instruction::use_iterator UI = phi->use_begin(); - incr = dyn_cast(UI); - if (!incr) - incr = dyn_cast(++UI); - // 1 use for postinc value, the phi. Unnecessarily conservative? - if (!incr || !incr->hasOneUse() || incr->getOpcode()!=Instruction::Add) - return; - } else { - // Value tested is postinc. Find the phi node. - incr = dyn_cast(Cond->getOperand(0)); - if (!incr || incr->getOpcode()!=Instruction::Add) + PHINode *PHIExpr; + Instruction *Incr; + if (User.isUseOfPostIncrementedValue) { + // Value tested is postinc. Find the phi node. + Incr = dyn_cast(CondOp0); + if (!Incr || Incr->getOpcode() != Instruction::Add) return; - Instruction::use_iterator UI = Cond->getOperand(0)->use_begin(); - phi = dyn_cast(UI); - if (!phi) - phi = dyn_cast(++UI); + Instruction::use_iterator UI = CondOp0->use_begin(); + PHIExpr = dyn_cast(UI); + if (!PHIExpr) + PHIExpr = dyn_cast(++UI); // 1 use for preinc value, the increment. - if (!phi || phi->getParent()!=L->getHeader() || !phi->hasOneUse()) + if (!PHIExpr || !PHIExpr->hasOneUse()) + return; + } else { + assert(isa(CondOp0) && + "Unexpected loop exiting counting instruction sequence!"); + PHIExpr = cast(CondOp0); + // Value tested is preinc. Find the increment. + // A CmpInst is not a BinaryOperator; we depend on this. + Instruction::use_iterator UI = PHIExpr->use_begin(); + Incr = dyn_cast(UI); + if (!Incr) + Incr = dyn_cast(++UI); + // One use for postinc value, the phi. Unnecessarily conservative? + if (!Incr || !Incr->hasOneUse() || Incr->getOpcode() != Instruction::Add) return; } // Replace the increment with a decrement. - BinaryOperator *decr = - BinaryOperator::Create(Instruction::Sub, incr->getOperand(0), - incr->getOperand(1), "tmp", incr); - incr->replaceAllUsesWith(decr); - incr->eraseFromParent(); + DEBUG(errs() << " Examining "); + if (User.isUseOfPostIncrementedValue) + DEBUG(errs() << "postinc"); + else + DEBUG(errs() << "preinc"); + DEBUG(errs() << " use "); + DEBUG(WriteAsOperand(errs(), CondOp0, /*PrintType=*/false)); + DEBUG(errs() << " in Inst: " << *Inst << '\n'); + BinaryOperator *Decr = BinaryOperator::Create(Instruction::Sub, + Incr->getOperand(0), Incr->getOperand(1), "tmp", Incr); + Incr->replaceAllUsesWith(Decr); + Incr->eraseFromParent(); // Substitute endval-startval for the original startval, and 0 for the // original endval. Since we're only testing for equality this is OK even // if the computation wraps around. BasicBlock *Preheader = L->getLoopPreheader(); Instruction *PreInsertPt = Preheader->getTerminator(); - int inBlock = L->contains(phi->getIncomingBlock(0)) ? 1 : 0; - Value *startVal = phi->getIncomingValue(inBlock); - Value *endVal = Cond->getOperand(1); - // FIXME check for case where both are constant + unsigned InBlock = L->contains(PHIExpr->getIncomingBlock(0)) ? 1 : 0; + Value *StartVal = PHIExpr->getIncomingValue(InBlock); + Value *EndVal = Cond->getOperand(1); + DEBUG(errs() << " Optimize loop counting iv to count down [" + << *EndVal << " .. " << *StartVal << "]\n"); + + // FIXME: check for case where both are constant. Constant* Zero = ConstantInt::get(Cond->getOperand(1)->getType(), 0); - BinaryOperator *NewStartVal = - BinaryOperator::Create(Instruction::Sub, endVal, startVal, - "tmp", PreInsertPt); - phi->setIncomingValue(inBlock, NewStartVal); + BinaryOperator *NewStartVal = BinaryOperator::Create(Instruction::Sub, + EndVal, StartVal, "tmp", PreInsertPt); + PHIExpr->setIncomingValue(InBlock, NewStartVal); Cond->setOperand(1, Zero); + DEBUG(errs() << " New icmp: " << *Cond << "\n"); Changed = true; + ++NumCountZero; } bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) { @@ -2581,11 +2618,20 @@ continue; StrengthReduceStridedIVUsers(SI->first, *SI->second, L); } - } - // After all sharing is done, see if we can adjust the loop to test against - // zero instead of counting up to a maximum. This is usually faster. - OptimizeLoopCountIV(L); + // After all sharing is done, see if we can adjust the loop to test against + // zero instead of counting up to a maximum. This is usually faster. + for (unsigned Stride = 0, e = IU->StrideOrder.size(); + Stride != e; ++Stride) { + std::map::iterator SI = + IU->IVUsesByStride.find(IU->StrideOrder[Stride]); + assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); + // FIXME: Generalize to non-affine IV's. + if (!SI->first->isLoopInvariant(L)) + continue; + OptimizeLoopCountIV(SI->first, *SI->second, L); + } + } // We're done analyzing this loop; release all the state we built up for it. IVsByStride.clear(); Added: llvm/trunk/test/Transforms/LoopStrengthReduce/count-to-zero.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/count-to-zero.ll?rev=86715&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/count-to-zero.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/count-to-zero.ll Tue Nov 10 15:14:05 2009 @@ -0,0 +1,42 @@ +; RUN: opt < %s -loop-reduce -S | FileCheck %s +; rdar://7382068 + +define void @t(i32 %c) nounwind optsize { +entry: + br label %bb6 + +bb1: ; preds = %bb6 + %tmp = icmp eq i32 %c_addr.1, 20 ; [#uses=1] + br i1 %tmp, label %bb2, label %bb3 + +bb2: ; preds = %bb1 + %tmp1 = tail call i32 @f20(i32 %c_addr.1) nounwind ; [#uses=1] + br label %bb7 + +bb3: ; preds = %bb1 + %tmp2 = icmp slt i32 %c_addr.1, 10 ; [#uses=1] + %tmp3 = add nsw i32 %c_addr.1, 1 ; [#uses=1] + %tmp4 = add i32 %c_addr.1, -1 ; [#uses=1] + %c_addr.1.be = select i1 %tmp2, i32 %tmp3, i32 %tmp4 ; [#uses=1] + %indvar.next = add i32 %indvar, 1 ; [#uses=1] +; CHECK: sub i32 %lsr.iv, 1 + br label %bb6 + +bb6: ; preds = %bb3, %entry + %indvar = phi i32 [ %indvar.next, %bb3 ], [ 0, %entry ] ; [#uses=2] + %c_addr.1 = phi i32 [ %c_addr.1.be, %bb3 ], [ %c, %entry ] ; [#uses=7] + %tmp5 = icmp eq i32 %indvar, 9999 ; [#uses=1] +; CHECK: icmp eq i32 %lsr.iv, 0 + %tmp6 = icmp eq i32 %c_addr.1, 100 ; [#uses=1] + %or.cond = or i1 %tmp5, %tmp6 ; [#uses=1] + br i1 %or.cond, label %bb7, label %bb1 + +bb7: ; preds = %bb6, %bb2 + %c_addr.0 = phi i32 [ %tmp1, %bb2 ], [ %c_addr.1, %bb6 ] ; [#uses=1] + tail call void @bar(i32 %c_addr.0) nounwind + ret void +} + +declare i32 @f20(i32) + +declare void @bar(i32) From echristo at apple.com Tue Nov 10 15:15:40 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 Nov 2009 13:15:40 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options: --verbose In-Reply-To: <7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55> References: <6AE1604EE3EC5F4296C096518C6B77EEF99C4FAA@mail.accesssoftek.com> <7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55> Message-ID: <4C3AAB5F-812D-4811-A1EE-DEF04E0F29EE@apple.com> On Nov 10, 2009, at 1:10 PM, Viktor Kutuzov wrote: > It'd be easier to look at if there were less cosmetic changes in the patch. That said, what do you expect this will add? -eric From sabre at nondot.org Tue Nov 10 15:40:01 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 21:40:01 -0000 Subject: [llvm-commits] [llvm] r86722 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911102140.nAALe21i002831@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 15:40:01 2009 New Revision: 86722 URL: http://llvm.org/viewvc/llvm-project?rev=86722&view=rev Log: Make jump threading eliminate blocks that just contain phi nodes, debug intrinsics, and an unconditional branch when possible. This reuses the TryToSimplifyUncondBranchFromEmptyBlock function split out of simplifycfg. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86722&r1=86721&r2=86722&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 15:40:01 2009 @@ -115,6 +115,7 @@ bool Changed = false; for (Function::iterator I = F.begin(), E = F.end(); I != E;) { BasicBlock *BB = I; + // Thread all of the branches we can over this block. while (ProcessBlock(BB)) Changed = true; @@ -129,6 +130,26 @@ LoopHeaders.erase(BB); DeleteDeadBlock(BB); Changed = true; + } else if (BranchInst *BI = dyn_cast(BB->getTerminator())) { + // Can't thread an unconditional jump, but if the block is "almost + // empty", we can replace uses of it with uses of the successor and make + // this dead. + if (BI->isUnconditional() && + BB != &BB->getParent()->getEntryBlock()) { + BasicBlock::iterator BBI = BB->getFirstNonPHI(); + // Ignore dbg intrinsics. + while (isa(BBI)) + ++BBI; + // If the terminator is the only non-phi instruction, try to nuke it. + if (BBI->isTerminator()) { + bool Erased = LoopHeaders.erase(BB); + + if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) + Changed = true; + else if (Erased) + LoopHeaders.insert(BB); + } + } } } AnotherIteration = Changed; Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86722&r1=86721&r2=86722&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Tue Nov 10 15:40:01 2009 @@ -211,19 +211,29 @@ T0: %A = call i1 @test8a() br i1 %A, label %T1, label %F1 + +; CHECK: T0: +; CHECK-NEXT: call +; CHECK-NEXT: br i1 %A, label %T1, label %Y + T1: %B = call i1 @test8a() br i1 %B, label %T2, label %F1 + +; CHECK: T1: +; CHECK-NEXT: call +; CHECK-NEXT: br i1 %B, label %T2, label %Y T2: %C = call i1 @test8a() br i1 %cond, label %T3, label %F1 + +; CHECK: T2: +; CHECK-NEXT: call +; CHECK-NEXT: br i1 %cond, label %T3, label %Y T3: ret i32 0 F1: -; TODO: F1 uncond branch block should be removed, T2 should jump directly to Y. -; CHECK: F1: -; CHECK-NEXT br label %Y %D = phi i32 [0, %T0], [0, %T1], [1, %T2] %E = icmp eq i32 %D, 1 %F = and i1 %E, %cond From sabre at nondot.org Tue Nov 10 15:45:09 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 21:45:09 -0000 Subject: [llvm-commits] [llvm] r86723 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911102145.nAALj9aC002980@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 15:45:09 2009 New Revision: 86723 URL: http://llvm.org/viewvc/llvm-project?rev=86723&view=rev Log: improve comment. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86723&r1=86722&r2=86723&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 15:45:09 2009 @@ -142,11 +142,14 @@ ++BBI; // If the terminator is the only non-phi instruction, try to nuke it. if (BBI->isTerminator()) { - bool Erased = LoopHeaders.erase(BB); + // Since TryToSimplifyUncondBranchFromEmptyBlock may delete the + // block, we have to make sure it isn't in the LoopHeaders set. We + // reinsert afterward in the rare case when the block isn't deleted. + bool ErasedFromLoopHeaders = LoopHeaders.erase(BB); if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) Changed = true; - else if (Erased) + else if (ErasedFromLoopHeaders) LoopHeaders.insert(BB); } } From stoklund at 2pi.dk Tue Nov 10 16:00:56 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Nov 2009 22:00:56 -0000 Subject: [llvm-commits] [llvm] r86724 - in /llvm/trunk/lib/CodeGen: PHIElimination.cpp PHIElimination.h Message-ID: <200911102200.nAAM0uSI003534@zion.cs.uiuc.edu> Author: stoklund Date: Tue Nov 10 16:00:56 2009 New Revision: 86724 URL: http://llvm.org/viewvc/llvm-project?rev=86724&view=rev Log: Refactoring: Extract method PHIElimination::isLiveOut(). Clean up some whitespace. No functional changes. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=86724&r1=86723&r2=86724&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Nov 10 16:00:56 2009 @@ -155,7 +155,7 @@ /// under the assuption that it needs to be lowered in a way that supports /// atomic execution of PHIs. This lowering method is always correct all of the /// time. -/// +/// void llvm::PHIElimination::LowerAtomicPHINode( MachineBasicBlock &MBB, MachineBasicBlock::iterator AfterPHIsIt) { @@ -186,7 +186,7 @@ } // Record PHI def. - assert(!hasPHIDef(DestReg) && "Vreg has multiple phi-defs?"); + assert(!hasPHIDef(DestReg) && "Vreg has multiple phi-defs?"); PHIDefs[DestReg] = &MBB; // Update live variable information if there is any. @@ -250,7 +250,7 @@ // basic block. if (!MBBsInsertedInto.insert(&opBlock)) continue; // If the copy has already been emitted, we're done. - + // Find a safe location to insert the copy, this may be the first terminator // in the block (or end()). MachineBasicBlock::iterator InsertPos = FindCopyInsertPoint(opBlock, SrcReg); @@ -260,82 +260,24 @@ // Now update live variable information if we have it. Otherwise we're done if (!LV) continue; - + // We want to be able to insert a kill of the register if this PHI (aka, the // copy we just inserted) is the last use of the source value. Live // variable analysis conservatively handles this by saying that the value is // live until the end of the block the PHI entry lives in. If the value // really is dead at the PHI copy, there will be no successor blocks which // have the value live-in. - // - // Check to see if the copy is the last use, and if so, update the live - // variables information so that it knows the copy source instruction kills - // the incoming value. - LiveVariables::VarInfo &InRegVI = LV->getVarInfo(SrcReg); - // Loop over all of the successors of the basic block, checking to see if - // the value is either live in the block, or if it is killed in the block. // Also check to see if this register is in use by another PHI node which // has not yet been eliminated. If so, it will be killed at an appropriate // point later. // Is it used by any PHI instructions in this block? - bool ValueIsLive = VRegPHIUseCount[BBVRegPair(&opBlock, SrcReg)] != 0; - - std::vector OpSuccBlocks; - - // Otherwise, scan successors, including the BB the PHI node lives in. - for (MachineBasicBlock::succ_iterator SI = opBlock.succ_begin(), - E = opBlock.succ_end(); SI != E && !ValueIsLive; ++SI) { - MachineBasicBlock *SuccMBB = *SI; - - // Is it alive in this successor? - unsigned SuccIdx = SuccMBB->getNumber(); - if (InRegVI.AliveBlocks.test(SuccIdx)) { - ValueIsLive = true; - break; - } - - OpSuccBlocks.push_back(SuccMBB); - } - - // Check to see if this value is live because there is a use in a successor - // that kills it. - if (!ValueIsLive) { - switch (OpSuccBlocks.size()) { - case 1: { - MachineBasicBlock *MBB = OpSuccBlocks[0]; - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (InRegVI.Kills[i]->getParent() == MBB) { - ValueIsLive = true; - break; - } - break; - } - case 2: { - MachineBasicBlock *MBB1 = OpSuccBlocks[0], *MBB2 = OpSuccBlocks[1]; - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (InRegVI.Kills[i]->getParent() == MBB1 || - InRegVI.Kills[i]->getParent() == MBB2) { - ValueIsLive = true; - break; - } - break; - } - default: - std::sort(OpSuccBlocks.begin(), OpSuccBlocks.end()); - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (std::binary_search(OpSuccBlocks.begin(), OpSuccBlocks.end(), - InRegVI.Kills[i]->getParent())) { - ValueIsLive = true; - break; - } - } - } + bool ValueIsUsed = VRegPHIUseCount[BBVRegPair(&opBlock, SrcReg)] != 0; // Okay, if we now know that the value is not live out of the block, we can // add a kill marker in this block saying that it kills the incoming value! - if (!ValueIsLive) { + if (!ValueIsUsed && !isLiveOut(SrcReg, opBlock, *LV)) { // In our final twist, we have to decide which instruction kills the // register. In most cases this is the copy, however, the first // terminator instruction at the end of the block may also use the value. @@ -346,7 +288,7 @@ if (Term != opBlock.end()) { if (Term->readsRegister(SrcReg)) KillInst = Term; - + // Check that no other terminators use values. #ifndef NDEBUG for (MachineBasicBlock::iterator TI = next(Term); TI != opBlock.end(); @@ -357,16 +299,16 @@ } #endif } - + // Finally, mark it killed. LV->addVirtualRegisterKilled(SrcReg, KillInst); // This vreg no longer lives all of the way through opBlock. unsigned opBlockNum = opBlock.getNumber(); - InRegVI.AliveBlocks.reset(opBlockNum); + LV->getVarInfo(SrcReg).AliveBlocks.reset(opBlockNum); } } - + // Really delete the PHI instruction now! MF.DeleteMachineInstr(MPhi); ++NumAtomic; @@ -386,3 +328,51 @@ ++VRegPHIUseCount[BBVRegPair(BBI->getOperand(i + 1).getMBB(), BBI->getOperand(i).getReg())]; } + +bool llvm::PHIElimination::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, + LiveVariables &LV) { + LiveVariables::VarInfo &InRegVI = LV.getVarInfo(Reg); + + // Loop over all of the successors of the basic block, checking to see if + // the value is either live in the block, or if it is killed in the block. + std::vector OpSuccBlocks; + + // Otherwise, scan successors, including the BB the PHI node lives in. + for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(), + E = MBB.succ_end(); SI != E; ++SI) { + MachineBasicBlock *SuccMBB = *SI; + + // Is it alive in this successor? + unsigned SuccIdx = SuccMBB->getNumber(); + if (InRegVI.AliveBlocks.test(SuccIdx)) + return true; + OpSuccBlocks.push_back(SuccMBB); + } + + // Check to see if this value is live because there is a use in a successor + // that kills it. + switch (OpSuccBlocks.size()) { + case 1: { + MachineBasicBlock *SuccMBB = OpSuccBlocks[0]; + for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) + if (InRegVI.Kills[i]->getParent() == SuccMBB) + return true; + break; + } + case 2: { + MachineBasicBlock *SuccMBB1 = OpSuccBlocks[0], *SuccMBB2 = OpSuccBlocks[1]; + for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) + if (InRegVI.Kills[i]->getParent() == SuccMBB1 || + InRegVI.Kills[i]->getParent() == SuccMBB2) + return true; + break; + } + default: + std::sort(OpSuccBlocks.begin(), OpSuccBlocks.end()); + for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) + if (std::binary_search(OpSuccBlocks.begin(), OpSuccBlocks.end(), + InRegVI.Kills[i]->getParent())) + return true; + } + return false; +} Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=86724&r1=86723&r2=86724&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Tue Nov 10 16:00:56 2009 @@ -89,6 +89,12 @@ /// void analyzePHINodes(const MachineFunction& Fn); + /// isLiveOut - Determine if Reg is live out from MBB, when not + /// considering PHI nodes. This means that Reg is either killed by + /// a successor block or passed through one. + bool isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, + LiveVariables &LV); + // FindCopyInsertPoint - Find a safe place in MBB to insert a copy from // SrcReg. This needs to be after any def or uses of SrcReg, but before // any subsequent point where control flow might jump out of the basic From stoklund at 2pi.dk Tue Nov 10 16:01:05 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Nov 2009 22:01:05 -0000 Subject: [llvm-commits] [llvm] r86725 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp lib/CodeGen/PHIElimination.cpp lib/CodeGen/PHIElimination.h Message-ID: <200911102201.nAAM15qf003564@zion.cs.uiuc.edu> Author: stoklund Date: Tue Nov 10 16:01:05 2009 New Revision: 86725 URL: http://llvm.org/viewvc/llvm-project?rev=86725&view=rev Log: Teach PHIElimination to split critical edges when -split-phi-edges is enabled. Critical edges leading to a PHI node are split when the PHI source variable is live out from the predecessor block. This help the coalescer eliminate more PHI joins. Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h llvm/trunk/lib/CodeGen/LiveVariables.cpp llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=86725&r1=86724&r2=86725&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Tue Nov 10 16:01:05 2009 @@ -103,7 +103,10 @@ Kills.erase(I); return true; } - + + /// findKill - Find a kill instruction in MBB. Return NULL if none is found. + MachineInstr *findKill(const MachineBasicBlock *MBB) const; + void dump() const; }; @@ -263,6 +266,10 @@ void HandleVirtRegDef(unsigned reg, MachineInstr *MI); void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MachineInstr *MI); + + /// addNewBlock - Add a new basic block A as an empty predecessor of B. All + /// variables that are live into B will be marked as passing live through A. + void addNewBlock(MachineBasicBlock *A, MachineBasicBlock *B); }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=86725&r1=86724&r2=86725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Tue Nov 10 16:01:05 2009 @@ -50,6 +50,14 @@ MachineFunctionPass::getAnalysisUsage(AU); } +MachineInstr * +LiveVariables::VarInfo::findKill(const MachineBasicBlock *MBB) const { + for (unsigned i = 0, e = Kills.size(); i != e; ++i) + if (Kills[i]->getParent() == MBB) + return Kills[i]; + return NULL; +} + void LiveVariables::VarInfo::dump() const { errs() << " Alive in blocks: "; for (SparseBitVector<>::iterator I = AliveBlocks.begin(), @@ -641,3 +649,35 @@ PHIVarInfo[BBI->getOperand(i + 1).getMBB()->getNumber()] .push_back(BBI->getOperand(i).getReg()); } + +void LiveVariables::addNewBlock(MachineBasicBlock *A, MachineBasicBlock *B) { + unsigned NumA = A->getNumber(); + unsigned NumB = B->getNumber(); + + // Update info for all live variables + for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) { + VarInfo &VI = VirtRegInfo[i]; + + // Anything live through B is also live through A. + if (VI.AliveBlocks.test(NumB)) { + VI.AliveBlocks.set(NumA); + continue; + } + + // If we're not killed in B, we are not live in + if (!VI.findKill(B)) + continue; + + unsigned Reg = i+TargetRegisterInfo::FirstVirtualRegister; + + // Find a def outside B + for (MachineRegisterInfo::def_iterator di = MRI->def_begin(Reg), + de=MRI->def_end(); di != de; ++di) { + if (di->getParent() != B) { + // Reg was defined outside B and killed in B - it must be live in. + VI.AliveBlocks.set(NumA); + break; + } + } + } +} Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=86725&r1=86724&r2=86725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Nov 10 16:01:05 2009 @@ -27,12 +27,20 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" #include #include using namespace llvm; STATISTIC(NumAtomic, "Number of atomic phis lowered"); +STATISTIC(NumSplits, "Number of critical edges split on demand"); + +static cl::opt +SplitEdges("split-phi-edges", + cl::desc("Split critical edges during phi elimination"), + cl::init(false), cl::Hidden); char PHIElimination::ID = 0; static RegisterPass @@ -41,10 +49,14 @@ const PassInfo *const llvm::PHIEliminationID = &X; void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); AU.addPreserved(); - AU.addPreservedID(MachineLoopInfoID); - AU.addPreservedID(MachineDominatorsID); + if (SplitEdges) { + AU.addRequired(); + } else { + AU.setPreservesCFG(); + AU.addPreservedID(MachineLoopInfoID); + AU.addPreservedID(MachineDominatorsID); + } MachineFunctionPass::getAnalysisUsage(AU); } @@ -84,6 +96,9 @@ if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI) return false; // Quick exit for basic blocks without PHIs. + if (SplitEdges) + SplitPHIEdges(MF, MBB); + // Get an iterator to the first instruction after the last PHI node (this may // also be the end of the basic block). MachineBasicBlock::iterator AfterPHIsIt = SkipPHIsAndLabels(MBB, MBB.begin()); @@ -277,7 +292,8 @@ // Okay, if we now know that the value is not live out of the block, we can // add a kill marker in this block saying that it kills the incoming value! - if (!ValueIsUsed && !isLiveOut(SrcReg, opBlock, *LV)) { + // When SplitEdges is enabled, the value is never live out. + if (!ValueIsUsed && (SplitEdges || !isLiveOut(SrcReg, opBlock, *LV))) { // In our final twist, we have to decide which instruction kills the // register. In most cases this is the copy, however, the first // terminator instruction at the end of the block may also use the value. @@ -329,6 +345,22 @@ BBI->getOperand(i).getReg())]; } +void llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF, + MachineBasicBlock &MBB) { + LiveVariables &LV = getAnalysis(); + for (MachineBasicBlock::const_iterator BBI = MBB.begin(), BBE = MBB.end(); + BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) { + for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) { + unsigned Reg = BBI->getOperand(i).getReg(); + MachineBasicBlock *PreMBB = BBI->getOperand(i+1).getMBB(); + // We break edges when registers are live out from the predecessor block + // (not considering PHI nodes). + if (isLiveOut(Reg, *PreMBB, LV)) + SplitCriticalEdge(PreMBB, &MBB); + } + } +} + bool llvm::PHIElimination::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, LiveVariables &LV) { LiveVariables::VarInfo &InRegVI = LV.getVarInfo(Reg); @@ -376,3 +408,43 @@ } return false; } + +MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, + MachineBasicBlock *B) { + assert(A && B && "Missing MBB end point"); + ++NumSplits; + + MachineFunction *MF = A->getParent(); + MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(B->getBasicBlock()); + MF->push_back(NMBB); + const unsigned NewNum = NMBB->getNumber(); + DEBUG(errs() << "PHIElimination splitting critical edge:" + " BB#" << A->getNumber() + << " -- BB#" << NewNum + << " -- BB#" << B->getNumber() << '\n'); + + A->ReplaceUsesOfBlockWith(B, NMBB); + NMBB->addSuccessor(B); + + // Insert unconditional "jump B" instruction in NMBB. + SmallVector Cond; + MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); + + LiveVariables *LV = getAnalysisIfAvailable(); + if (LV) + LV->addNewBlock(NMBB, B); + + // Fix PHI nodes in B so they refer to NMBB instead of A + for (MachineBasicBlock::iterator i = B->begin(), e = B->end(); + i != e && i->getOpcode() == TargetInstrInfo::PHI; ++i) + for (unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2) + if (i->getOperand(ni+1).getMBB() == A) { + i->getOperand(ni+1).setMBB(NMBB); + // Mark PHI sources as passing live through NMBB + if (LV) + LV->getVarInfo(i->getOperand(ni).getReg()).AliveBlocks.set(NewNum); + } + return NMBB; +} + + Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=86725&r1=86724&r2=86725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Tue Nov 10 16:01:05 2009 @@ -89,12 +89,21 @@ /// void analyzePHINodes(const MachineFunction& Fn); + /// Split critical edges where necessary for good coalescer performance. + void SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB); + /// isLiveOut - Determine if Reg is live out from MBB, when not /// considering PHI nodes. This means that Reg is either killed by /// a successor block or passed through one. bool isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, LiveVariables &LV); + /// SplitCriticalEdge - Split a critical edge from A to B by + /// inserting a new MBB. Update branches in A and PHI instructions + /// in B. Return the new block. + MachineBasicBlock *SplitCriticalEdge(MachineBasicBlock *A, + MachineBasicBlock *B); + // FindCopyInsertPoint - Find a safe place in MBB to insert a copy from // SrcReg. This needs to be after any def or uses of SrcReg, but before // any subsequent point where control flow might jump out of the basic From sabre at nondot.org Tue Nov 10 16:02:09 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 22:02:09 -0000 Subject: [llvm-commits] [llvm] r86726 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/crash.ll Message-ID: <200911102202.nAAM29cT003603@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 16:02:09 2009 New Revision: 86726 URL: http://llvm.org/viewvc/llvm-project?rev=86726&view=rev Log: fix a crash in SCCP handling extractvalue of an array, pointed out and tracked down by Stephan Reiter! Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=86726&r1=86725&r2=86726&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Nov 10 16:02:09 2009 @@ -795,9 +795,14 @@ return markOverdefined(&EVI); Value *AggVal = EVI.getAggregateOperand(); - unsigned i = *EVI.idx_begin(); - LatticeVal EltVal = getStructValueState(AggVal, i); - mergeInValue(getValueState(&EVI), &EVI, EltVal); + if (isa(AggVal->getType())) { + unsigned i = *EVI.idx_begin(); + LatticeVal EltVal = getStructValueState(AggVal, i); + mergeInValue(getValueState(&EVI), &EVI, EltVal); + } else { + // Otherwise, must be extracting from an array. + return markOverdefined(&EVI); + } } void SCCPSolver::visitInsertValueInst(InsertValueInst &IVI) { Modified: llvm/trunk/test/Transforms/SCCP/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/crash.ll?rev=86726&r1=86725&r2=86726&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/crash.ll (original) +++ llvm/trunk/test/Transforms/SCCP/crash.ll Tue Nov 10 16:02:09 2009 @@ -22,3 +22,8 @@ return: ret void } + +define i32 @test2([4 x i32] %A) { + %B = extractvalue [4 x i32] %A, 1 + ret i32 %B +} From dpatel at apple.com Tue Nov 10 16:05:35 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Nov 2009 22:05:35 -0000 Subject: [llvm-commits] [llvm] r86727 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <200911102205.nAAM5aOF003756@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 16:05:35 2009 New Revision: 86727 URL: http://llvm.org/viewvc/llvm-project?rev=86727&view=rev Log: Process InlinedAt location info. Update InsertDeclare to return newly inserted llvm.dbg.declare intrinsic. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=86727&r1=86726&r2=86727&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Nov 10 16:05:35 2009 @@ -623,12 +623,12 @@ void InsertRegionEnd(DIDescriptor D, BasicBlock *BB); /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. - void InsertDeclare(llvm::Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd); + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + BasicBlock *InsertAtEnd); /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. - void InsertDeclare(llvm::Value *Storage, DIVariable D, - Instruction *InsertBefore); + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + Instruction *InsertBefore); private: Constant *GetTagConstant(unsigned TAG); @@ -731,6 +731,9 @@ /// processDeclare - Process DbgDeclareInst. void processDeclare(DbgDeclareInst *DDI); + /// processLocation - Process DILocation. + void processLocation(DILocation Loc); + /// addCompileUnit - Add compile unit into CUs. bool addCompileUnit(DICompileUnit CU); Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86727&r1=86726&r2=86727&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Nov 10 16:05:35 2009 @@ -1036,7 +1036,7 @@ } /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. -void DIFactory::InsertDeclare(Value *Storage, DIVariable D, +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *InsertBefore) { // Cast the storage to a {}* for the call to llvm.dbg.declare. Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); @@ -1045,11 +1045,11 @@ DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); Value *Args[] = { Storage, D.getNode() }; - CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); } /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. -void DIFactory::InsertDeclare(Value *Storage, DIVariable D, +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, BasicBlock *InsertAtEnd) { // Cast the storage to a {}* for the call to llvm.dbg.declare. Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); @@ -1058,7 +1058,7 @@ DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); Value *Args[] = { Storage, D.getNode() }; - CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); } @@ -1088,18 +1088,9 @@ else if (DbgDeclareInst *DDI = dyn_cast(BI)) processDeclare(DDI); #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - else if (MDDbgKind) { - if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) { - DILocation Loc(L); - DIScope S(Loc.getScope().getNode()); - if (S.isCompileUnit()) - addCompileUnit(DICompileUnit(S.getNode())); - else if (S.isSubprogram()) - processSubprogram(DISubprogram(S.getNode())); - else if (S.isLexicalBlock()) - processLexicalBlock(DILexicalBlock(S.getNode())); - } - } + else if (MDDbgKind) + if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) + processLocation(DILocation(L)); #endif } @@ -1116,6 +1107,20 @@ } } +/// processLocation - Process DILocation. +void DebugInfoFinder::processLocation(DILocation Loc) { + if (Loc.isNull()) return; + DIScope S(Loc.getScope().getNode()); + if (S.isNull()) return; + if (S.isCompileUnit()) + addCompileUnit(DICompileUnit(S.getNode())); + else if (S.isSubprogram()) + processSubprogram(DISubprogram(S.getNode())); + else if (S.isLexicalBlock()) + processLexicalBlock(DILexicalBlock(S.getNode())); + processLocation(Loc.getOrigLocation()); +} + /// processType - Process DIType. void DebugInfoFinder::processType(DIType DT) { if (!addType(DT)) From clattner at apple.com Tue Nov 10 16:05:54 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 10 Nov 2009 14:05:54 -0800 Subject: [llvm-commits] [llvm] r86525 - /llvm/trunk/lib/VMCore/Instructions.cpp In-Reply-To: <745D848F-B85D-4F45-B265-EABAD791A9AC@apple.com> References: <200911090712.nA97C1pV013033@zion.cs.uiuc.edu> <745D848F-B85D-4F45-B265-EABAD791A9AC@apple.com> Message-ID: <9007D5DF-BE6E-4FC1-86DA-8BAC1C6BDBDB@apple.com> thanks! On Nov 10, 2009, at 11:54 AM, Victor Hernandez wrote: > I just realized that this patch only fixed this for CreateFree(), but > it also needs to be fixed in CreateMalloc(). > Fixed CreateMalloc() in r86712. > > Victor > > On Nov 8, 2009, at 11:12 PM, Chris Lattner wrote: > >> Author: lattner >> Date: Mon Nov 9 01:12:01 2009 >> New Revision: 86525 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86525&view=rev >> Log: >> make this handle redefinition of malloc with different prototype >> correctly. >> >> Modified: >> llvm/trunk/lib/VMCore/Instructions.cpp >> >> Modified: llvm/trunk/lib/VMCore/Instructions.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86525&r1=86524&r2=86525&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/VMCore/Instructions.cpp (original) >> +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Nov 9 01:12:01 2009 >> @@ -568,8 +568,7 @@ >> const Type *VoidTy = Type::getVoidTy(M->getContext()); >> const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); >> // prototype free as "void free(void*)" >> - Function *FreeFunc = cast(M->getOrInsertFunction >> ("free", VoidTy, >> - >> IntPtrTy, NULL)); >> + Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, >> IntPtrTy, NULL); >> CallInst* Result = NULL; >> Value *PtrCast = Source; >> if (InsertBefore) { >> @@ -582,7 +581,8 @@ >> Result = CallInst::Create(FreeFunc, PtrCast, ""); >> } >> Result->setTailCall(); >> - Result->setCallingConv(FreeFunc->getCallingConv()); >> + if (Function *F = dyn_cast(FreeFunc)) >> + Result->setCallingConv(F->getCallingConv()); >> >> return Result; >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Tue Nov 10 16:14:05 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Nov 2009 22:14:05 -0000 Subject: [llvm-commits] [llvm] r86729 - in /llvm/trunk: lib/Target/PowerPC/PPCRegisterInfo.cpp test/CodeGen/PowerPC/ppc-prologue.ll Message-ID: <200911102214.nAAME5Dk004068@zion.cs.uiuc.edu> Author: void Date: Tue Nov 10 16:14:04 2009 New Revision: 86729 URL: http://llvm.org/viewvc/llvm-project?rev=86729&view=rev Log: Modify how the prologue encoded the "move" information for the FDE. GCC generates a sequence similar to this: __Z4funci: LFB2: mflr r0 LCFI0: stmw r30,-8(r1) LCFI1: stw r0,8(r1) LCFI2: stwu r1,-80(r1) LCFI3: mr r30,r1 LCFI4: where LCFI3 and LCFI4 are used by the FDE to indicate what the FP, LR, and other things are. We generated something more like this: Leh_func_begin1: mflr r0 stw r31, 20(r1) stw r0, 8(r1) Llabel1: stwu r1, -80(r1) Llabel2: mr r31, r1 Note that we are missing the "mr" instruction. This patch makes it more like the GCC output. Added: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=86729&r1=86728&r2=86729&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Tue Nov 10 16:14:04 2009 @@ -1356,12 +1356,6 @@ unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); unsigned MaxAlign = MFI->getMaxAlignment(); - if (needsFrameMoves) { - // Mark effective beginning of when frame pointer becomes valid. - FrameLabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addImm(FrameLabelId); - } - // Adjust stack pointer: r1 += NegFrameSize. // If there is a preferred stack alignment, align R1 now if (!IsPPC64) { @@ -1431,12 +1425,18 @@ .addReg(PPC::X0); } } + + std::vector &Moves = MMI->getFrameMoves(); + // Add the "machine moves" for the instructions we generated above, but in + // reverse order. if (needsFrameMoves) { - std::vector &Moves = MMI->getFrameMoves(); - + // Mark effective beginning of when frame pointer becomes valid. + FrameLabelId = MMI->NextLabelID(); + BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addImm(FrameLabelId); + + // Show update of SP. if (NegFrameSize) { - // Show update of SP. MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize); Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); @@ -1451,31 +1451,15 @@ Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); } - // Add callee saved registers to move list. - const std::vector &CSI = MFI->getCalleeSavedInfo(); - for (unsigned I = 0, E = CSI.size(); I != E; ++I) { - int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); - unsigned Reg = CSI[I].getReg(); - if (Reg == PPC::LR || Reg == PPC::LR8 || Reg == PPC::RM) continue; - MachineLocation CSDst(MachineLocation::VirtualFP, Offset); - MachineLocation CSSrc(Reg); - Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); + if (MustSaveLR) { + MachineLocation LRDst(MachineLocation::VirtualFP, LROffset); + MachineLocation LRSrc(IsPPC64 ? PPC::LR8 : PPC::LR); + Moves.push_back(MachineMove(FrameLabelId, LRDst, LRSrc)); } - - MachineLocation LRDst(MachineLocation::VirtualFP, LROffset); - MachineLocation LRSrc(IsPPC64 ? PPC::LR8 : PPC::LR); - Moves.push_back(MachineMove(FrameLabelId, LRDst, LRSrc)); - - // Mark effective beginning of when frame pointer is ready. - unsigned ReadyLabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addImm(ReadyLabelId); - - MachineLocation FPDst(HasFP ? (IsPPC64 ? PPC::X31 : PPC::R31) : - (IsPPC64 ? PPC::X1 : PPC::R1)); - MachineLocation FPSrc(MachineLocation::VirtualFP); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); } + unsigned ReadyLabelId = 0; + // If there is a frame pointer, copy R1 into R31 if (HasFP) { if (!IsPPC64) { @@ -1487,6 +1471,33 @@ .addReg(PPC::X1) .addReg(PPC::X1); } + + if (needsFrameMoves) { + ReadyLabelId = MMI->NextLabelID(); + + // Mark effective beginning of when frame pointer is ready. + BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addImm(ReadyLabelId); + + MachineLocation FPDst(HasFP ? (IsPPC64 ? PPC::X31 : PPC::R31) : + (IsPPC64 ? PPC::X1 : PPC::R1)); + MachineLocation FPSrc(MachineLocation::VirtualFP); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + } + } + + if (needsFrameMoves) { + unsigned LabelId = HasFP ? ReadyLabelId : FrameLabelId; + + // Add callee saved registers to move list. + const std::vector &CSI = MFI->getCalleeSavedInfo(); + for (unsigned I = 0, E = CSI.size(); I != E; ++I) { + int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); + unsigned Reg = CSI[I].getReg(); + if (Reg == PPC::LR || Reg == PPC::LR8 || Reg == PPC::RM) continue; + MachineLocation CSDst(MachineLocation::VirtualFP, Offset); + MachineLocation CSSrc(Reg); + Moves.push_back(MachineMove(LabelId, CSDst, CSSrc)); + } } } Added: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll?rev=86729&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Tue Nov 10 16:14:04 2009 @@ -0,0 +1,28 @@ +; RUN: llc < %s -march=ppc32 -disable-fp-elim | FileCheck %s + +define i32 @_Z4funci(i32 %a) ssp { +; CHECK: mflr r0 +; CHECK-NEXT: stw r31, 20(r1) +; CHECK-NEXT: stw r0, 8(r1) +; CHECK-NEXT: stwu r1, -80(r1) +; CHECK-NEXT: Llabel1: +; CHECK-NEXT: mr r31, r1 +; CHECK-NEXT: Llabel2: +entry: + %a_addr = alloca i32 ; [#uses=2] + %retval = alloca i32 ; [#uses=2] + %0 = alloca i32 ; [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 %a, i32* %a_addr + %1 = call i32 @_Z3barPi(i32* %a_addr) ; [#uses=1] + store i32 %1, i32* %0, align 4 + %2 = load i32* %0, align 4 ; [#uses=1] + store i32 %2, i32* %retval, align 4 + br label %return + +return: ; preds = %entry + %retval1 = load i32* %retval ; [#uses=1] + ret i32 %retval1 +} + +declare i32 @_Z3barPi(i32*) From gohman at apple.com Tue Nov 10 16:16:58 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Nov 2009 22:16:58 -0000 Subject: [llvm-commits] [llvm] r86732 - /llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Message-ID: <200911102216.nAAMGwju004195@zion.cs.uiuc.edu> Author: djg Date: Tue Nov 10 16:16:57 2009 New Revision: 86732 URL: http://llvm.org/viewvc/llvm-project?rev=86732&view=rev Log: Don't mark conditional branch instructions as control barriers. Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td?rev=86732&r1=86731&r2=86732&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Tue Nov 10 16:16:57 2009 @@ -3601,21 +3601,23 @@ (BRASL texternalsym:$func)>; // Unconditional branches: -let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in { - def BR : - UncondBranch<0b001001100, (outs), (ins brtarget:$dest), - "br\t$dest", - [(br bb:$dest)]>; - - // Unconditional, absolute address branch - def BRA: - UncondBranch<0b001100000, (outs), (ins brtarget:$dest), - "bra\t$dest", - [/* no pattern */]>; - - // Indirect branch - def BI: - BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>; +let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in { + let isBarrier = 1 in { + def BR : + UncondBranch<0b001001100, (outs), (ins brtarget:$dest), + "br\t$dest", + [(br bb:$dest)]>; + + // Unconditional, absolute address branch + def BRA: + UncondBranch<0b001100000, (outs), (ins brtarget:$dest), + "bra\t$dest", + [/* no pattern */]>; + + // Indirect branch + def BI: + BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>; + } // Conditional branches: class BRNZInst pattern>: From dpatel at apple.com Tue Nov 10 16:23:59 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Nov 2009 22:23:59 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86734 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200911102223.nAAMNxhD004436@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 16:23:59 2009 New Revision: 86734 URL: http://llvm.org/viewvc/llvm-project?rev=86734&view=rev Log: Use "" as input file name if stdin is input source. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=86734&r1=86733&r2=86734&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Nov 10 16:23:59 2009 @@ -934,15 +934,22 @@ // code generator accepts maximum one main compile unit per module. If a // module does not contain any main compile unit then the code generator // will emit multiple compile units in the output object file. - getOrCreateCompileUnit(main_input_filename, true); + if (!strcmp (main_input_filename, "")) + getOrCreateCompileUnit("", true); + else + getOrCreateCompileUnit(main_input_filename, true); } /// getOrCreateCompileUnit - Get the compile unit from the cache or /// create a new one if necessary. DICompileUnit DebugInfo::getOrCreateCompileUnit(const char *FullPath, bool isMain) { - if (!FullPath) - FullPath = main_input_filename; + if (!FullPath) { + if (!strcmp (main_input_filename, "")) + FullPath = ""; + else + FullPath = main_input_filename; + } std::map::iterator I = CUCache.find(FullPath); if (I != CUCache.end()) if (Value *M = I->second) From sabre at nondot.org Tue Nov 10 16:26:15 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 22:26:15 -0000 Subject: [llvm-commits] [llvm] r86735 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h include/llvm/Transforms/Utils/Local.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Utils/Local.cpp Message-ID: <200911102226.nAAMQFp1004527@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 16:26:15 2009 New Revision: 86735 URL: http://llvm.org/viewvc/llvm-project?rev=86735&view=rev Log: move some generally useful functions out of jump threading into libanalysis and transformutils. Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=86735&r1=86734&r2=86735&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original) +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Tue Nov 10 16:26:15 2009 @@ -59,6 +59,15 @@ /// instruction. If not, this returns null. Value *SimplifyInstruction(Instruction *I, const TargetData *TD = 0); + + /// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then + /// delete the From instruction. In addition to a basic RAUW, this does a + /// recursive simplification of the updated instructions. This catches + /// things where one simplification exposes other opportunities. This only + /// simplifies and deletes scalar operations, it does not change the CFG. + /// + void ReplaceAndSimplifyAllUses(Instruction *From, Value *To, + const TargetData *TD = 0); } // end namespace llvm #endif Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=86735&r1=86734&r2=86735&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Nov 10 16:26:15 2009 @@ -78,6 +78,21 @@ // Control Flow Graph Restructuring. // +/// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this +/// method is called when we're about to delete Pred as a predecessor of BB. If +/// BB contains any PHI nodes, this drops the entries in the PHI nodes for Pred. +/// +/// Unlike the removePredecessor method, this attempts to simplify uses of PHI +/// nodes that collapse into identity values. For example, if we have: +/// x = phi(1, 0, 0, 0) +/// y = and x, z +/// +/// .. and delete the predecessor corresponding to the '1', this will attempt to +/// recursively fold the 'and' to 0. +void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, + TargetData *TD = 0); + + /// MergeBasicBlockIntoOnlyPred - BB is a block with one predecessor and its /// predecessor is known to have one successor (BB!). Eliminate the edge /// between them, moving the instructions in the predecessor into BB. This Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=86735&r1=86734&r2=86735&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue Nov 10 16:26:15 2009 @@ -15,6 +15,7 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Support/ValueHandle.h" #include "llvm/Instructions.h" #include "llvm/Support/PatternMatch.h" using namespace llvm; @@ -311,3 +312,37 @@ } } +/// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then +/// delete the From instruction. In addition to a basic RAUW, this does a +/// recursive simplification of the newly formed instructions. This catches +/// things where one simplification exposes other opportunities. This only +/// simplifies and deletes scalar operations, it does not change the CFG. +/// +void llvm::ReplaceAndSimplifyAllUses(Instruction *From, Value *To, + const TargetData *TD) { + assert(From != To && "ReplaceAndSimplifyAllUses(X,X) is not valid!"); + + // FromHandle - This keeps a weakvh on the from value so that we can know if + // it gets deleted out from under us in a recursive simplification. + WeakVH FromHandle(From); + + while (!From->use_empty()) { + // Update the instruction to use the new value. + Use &U = From->use_begin().getUse(); + Instruction *User = cast(U.getUser()); + U = To; + + // See if we can simplify it. + if (Value *V = SimplifyInstruction(User, TD)) { + // Recursively simplify this. + ReplaceAndSimplifyAllUses(User, V, TD); + + // If the recursive simplification ended up revisiting and deleting 'From' + // then we're done. + if (FromHandle == 0) + return; + } + } + From->eraseFromParent(); +} + Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86735&r1=86734&r2=86735&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 16:26:15 2009 @@ -203,89 +203,6 @@ return Size; } - -//===----------------------------------------------------------------------===// - -/// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then -/// delete the From instruction. In addition to a basic RAUW, this does a -/// recursive simplification of the newly formed instructions. This catches -/// things where one simplification exposes other opportunities. This only -/// simplifies and deletes scalar operations, it does not change the CFG. -/// -static void ReplaceAndSimplifyAllUses(Instruction *From, Value *To, - const TargetData *TD) { - assert(From != To && "ReplaceAndSimplifyAllUses(X,X) is not valid!"); - - // FromHandle - This keeps a weakvh on the from value so that we can know if - // it gets deleted out from under us in a recursive simplification. - WeakVH FromHandle(From); - - while (!From->use_empty()) { - // Update the instruction to use the new value. - Use &U = From->use_begin().getUse(); - Instruction *User = cast(U.getUser()); - U = To; - - // See if we can simplify it. - if (Value *V = SimplifyInstruction(User, TD)) { - // Recursively simplify this. - ReplaceAndSimplifyAllUses(User, V, TD); - - // If the recursive simplification ended up revisiting and deleting 'From' - // then we're done. - if (FromHandle == 0) - return; - } - } - From->eraseFromParent(); -} - - -/// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this -/// method is called when we're about to delete Pred as a predecessor of BB. If -/// BB contains any PHI nodes, this drops the entries in the PHI nodes for Pred. -/// -/// Unlike the removePredecessor method, this attempts to simplify uses of PHI -/// nodes that collapse into identity values. For example, if we have: -/// x = phi(1, 0, 0, 0) -/// y = and x, z -/// -/// .. and delete the predecessor corresponding to the '1', this will attempt to -/// recursively fold the and to 0. -static void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, - TargetData *TD) { - // This only adjusts blocks with PHI nodes. - if (!isa(BB->begin())) - return; - - // Remove the entries for Pred from the PHI nodes in BB, but do not simplify - // them down. This will leave us with single entry phi nodes and other phis - // that can be removed. - BB->removePredecessor(Pred, true); - - WeakVH PhiIt = &BB->front(); - while (PHINode *PN = dyn_cast(PhiIt)) { - PhiIt = &*++BasicBlock::iterator(cast(PhiIt)); - - Value *PNV = PN->hasConstantValue(); - if (PNV == 0) continue; - - // If we're able to simplify the phi to a single value, substitute the new - // value into all of its uses. - assert(PNV != PN && "hasConstantValue broken"); - - ReplaceAndSimplifyAllUses(PN, PNV, TD); - - // If recursive simplification ended up deleting the next PHI node we would - // iterate to, then our iterator is invalid, restart scanning from the top - // of the block. - if (PhiIt == 0) PhiIt = &BB->front(); - } -} - -//===----------------------------------------------------------------------===// - - /// FindLoopHeaders - We do not want jump threading to turn proper loop /// structures into irreducible loops. Doing this breaks up the loop nesting /// hierarchy and pessimizes later transformations. To prevent this from Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=86735&r1=86734&r2=86735&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Nov 10 16:26:15 2009 @@ -24,6 +24,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/DebugInfo.h" +#include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/CFG.h" @@ -239,7 +240,7 @@ //===----------------------------------------------------------------------===// -// Local dead code elimination... +// Local dead code elimination. // /// isInstructionTriviallyDead - Return true if the result produced by the @@ -326,9 +327,53 @@ } //===----------------------------------------------------------------------===// -// Control Flow Graph Restructuring... +// Control Flow Graph Restructuring. // + +/// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this +/// method is called when we're about to delete Pred as a predecessor of BB. If +/// BB contains any PHI nodes, this drops the entries in the PHI nodes for Pred. +/// +/// Unlike the removePredecessor method, this attempts to simplify uses of PHI +/// nodes that collapse into identity values. For example, if we have: +/// x = phi(1, 0, 0, 0) +/// y = and x, z +/// +/// .. and delete the predecessor corresponding to the '1', this will attempt to +/// recursively fold the and to 0. +void llvm::RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, + TargetData *TD) { + // This only adjusts blocks with PHI nodes. + if (!isa(BB->begin())) + return; + + // Remove the entries for Pred from the PHI nodes in BB, but do not simplify + // them down. This will leave us with single entry phi nodes and other phis + // that can be removed. + BB->removePredecessor(Pred, true); + + WeakVH PhiIt = &BB->front(); + while (PHINode *PN = dyn_cast(PhiIt)) { + PhiIt = &*++BasicBlock::iterator(cast(PhiIt)); + + Value *PNV = PN->hasConstantValue(); + if (PNV == 0) continue; + + // If we're able to simplify the phi to a single value, substitute the new + // value into all of its uses. + assert(PNV != PN && "hasConstantValue broken"); + + ReplaceAndSimplifyAllUses(PN, PNV, TD); + + // If recursive simplification ended up deleting the next PHI node we would + // iterate to, then our iterator is invalid, restart scanning from the top + // of the block. + if (PhiIt == 0) PhiIt = &BB->front(); + } +} + + /// MergeBasicBlockIntoOnlyPred - DestBB is a block with one predecessor and its /// predecessor is known to have one successor (DestBB!). Eliminate the edge /// between them, moving the instructions in the predecessor into DestBB and From sabre at nondot.org Tue Nov 10 16:39:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 22:39:17 -0000 Subject: [llvm-commits] [llvm] r86739 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911102239.nAAMdHpr005071@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 16:39:16 2009 New Revision: 86739 URL: http://llvm.org/viewvc/llvm-project?rev=86739&view=rev Log: implement a TODO by teaching jump threading about "xor x, 1". Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86739&r1=86738&r2=86739&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 16:39:16 2009 @@ -299,8 +299,20 @@ return !Result.empty(); } - // TODO: Should handle the NOT form of XOR. - + // Handle the NOT form of XOR. + if (I->getOpcode() == Instruction::Xor && + isa(I->getOperand(1)) && + cast(I->getOperand(1))->isOne()) { + ComputeValueKnownInPredecessors(I->getOperand(0), BB, Result); + if (Result.empty()) + return false; + + // Invert the known values. + for (unsigned i = 0, e = Result.size(); i != e; ++i) + Result[i].first = + cast(ConstantExpr::getNot(Result[i].first)); + return true; + } } // Handle compare with phi operand, where the PHI is defined in this block. Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86739&r1=86738&r2=86739&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Tue Nov 10 16:39:16 2009 @@ -245,3 +245,42 @@ ret i32 2 } + +;;; Verify that we can handle constraint propagation through "xor x, 1". +define i32 @test9(i1 %cond, i1 %cond2) { +Entry: +; CHECK: @test9 + %v1 = call i32 @f1() + br i1 %cond, label %Merge, label %F1 + +; CHECK: Entry: +; CHECK-NEXT: %v1 = call i32 @f1() +; CHECK-NEXT: br i1 %cond, label %F2, label %Merge + +F1: + %v2 = call i32 @f2() + br label %Merge + +Merge: + %B = phi i32 [%v1, %Entry], [%v2, %F1] + %M = icmp eq i32 %B, %v1 + %M1 = xor i1 %M, 1 + %N = icmp eq i32 %B, 47 + %O = and i1 %M1, %N + br i1 %O, label %T2, label %F2 + +; CHECK: Merge: +; CHECK-NOT: phi +; CHECK-NEXT: %v2 = call i32 @f2() + +T2: + %Q = zext i1 %M to i32 + ret i32 %Q + +F2: + ret i32 %B +; CHECK: F2: +; CHECK-NEXT: phi i32 +} + + From wendling at apple.com Tue Nov 10 16:39:36 2009 From: wendling at apple.com (Bill Wendling) Date: Tue, 10 Nov 2009 14:39:36 -0800 Subject: [llvm-commits] [llvm] r86729 - in /llvm/trunk: lib/Target/PowerPC/PPCRegisterInfo.cpp test/CodeGen/PowerPC/ppc-prologue.ll In-Reply-To: <200911102214.nAAME5Dk004068@zion.cs.uiuc.edu> References: <200911102214.nAAME5Dk004068@zion.cs.uiuc.edu> Message-ID: <343771B2-2B31-4D1C-B5C1-1F935FCBF808@apple.com> On Nov 10, 2009, at 2:14 PM, Bill Wendling wrote: > Author: void > Date: Tue Nov 10 16:14:04 2009 > New Revision: 86729 > > URL: http://llvm.org/viewvc/llvm-project?rev=86729&view=rev > Log: > Modify how the prologue encoded the "move" information for the FDE. > GCC > generates a sequence similar to this: > > __Z4funci: > LFB2: > mflr r0 > LCFI0: > stmw r30,-8(r1) > LCFI1: > stw r0,8(r1) > LCFI2: > stwu r1,-80(r1) > LCFI3: > mr r30,r1 > LCFI4: > > where LCFI3 and LCFI4 are used by the FDE to indicate what the FP, > LR, and other > things are. We generated something more like this: > > Leh_func_begin1: > mflr r0 > stw r31, 20(r1) > stw r0, 8(r1) > Llabel1: > stwu r1, -80(r1) > Llabel2: > mr r31, r1 > > Note that we are missing the "mr" instruction. This patch makes it > more like the > GCC output. A clarification: I don't mean that the mr instruction wasn't in the original output, but only that it wasn't properly reported in the FDE. -bw From vkutuzov at accesssoftek.com Tue Nov 10 16:47:23 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Tue, 10 Nov 2009 14:47:23 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options: --verbose References: <6AE1604EE3EC5F4296C096518C6B77EEF99C4FAA@mail.accesssoftek.com> <7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55> <4C3AAB5F-812D-4811-A1EE-DEF04E0F29EE@apple.com> Message-ID: <214DD1AE30F746F5B0086F4773D23D32@andreic6e7fe55> Please find attached the patch without cosmetic changes. Best regards, Viktor ----- Original Message ----- From: "Eric Christopher" To: "Viktor Kutuzov" Cc: "Commit Messages and Patches for LLVM" Sent: Tuesday, November 10, 2009 1:15 PM Subject: Re: [llvm-commits] [PATCH] LTO code generator options: --verbose On Nov 10, 2009, at 1:10 PM, Viktor Kutuzov wrote: > It'd be easier to look at if there were less cosmetic changes in the patch. That said, what do you expect this will add? -eric -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-lto-codegen_verbose.diff Type: application/octet-stream Size: 3574 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091110/a89dbc1a/attachment.obj From sabre at nondot.org Tue Nov 10 16:56:15 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 22:56:15 -0000 Subject: [llvm-commits] [llvm] r86747 - /llvm/trunk/include/llvm/Analysis/CFGPrinter.h Message-ID: <200911102256.nAAMuFFZ006044@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 16:56:15 2009 New Revision: 86747 URL: http://llvm.org/viewvc/llvm-project?rev=86747&view=rev Log: in -dot-cfg and -dot-cfg-only, when rendering switch instructions, put the switch value in the successor boxes like we put T/F for branches. Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=86747&r1=86746&r2=86747&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Tue Nov 10 16:56:15 2009 @@ -71,6 +71,18 @@ if (const BranchInst *BI = dyn_cast(Node->getTerminator())) if (BI->isConditional()) return (I == succ_begin(Node)) ? "T" : "F"; + + // Label source of conditional branches with "T" or "F" + if (const SwitchInst *SI = dyn_cast(Node->getTerminator())) { + unsigned SuccNo = I.getSuccessorIndex(); + + if (SuccNo == 0) return "def"; + + std::string Str; + raw_string_ostream OS(Str); + OS << SI->getCaseValue(SuccNo)->getValue(); + return OS.str(); + } return ""; } }; From dpatel at apple.com Tue Nov 10 17:06:00 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Nov 2009 23:06:00 -0000 Subject: [llvm-commits] [llvm] r86748 - in /llvm/trunk: include/llvm/Analysis/ include/llvm/CodeGen/ include/llvm/Transforms/Utils/ lib/Analysis/ lib/CodeGen/AsmPrinter/ lib/CodeGen/SelectionDAG/ lib/Transforms/Utils/ Message-ID: <200911102306.nAAN61b2006429@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 17:06:00 2009 New Revision: 86748 URL: http://llvm.org/viewvc/llvm-project?rev=86748&view=rev Log: Implement support to debug inlined functions. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/CodeGen/DwarfWriter.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/include/llvm/Transforms/Utils/Cloning.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Nov 10 17:06:00 2009 @@ -693,12 +693,6 @@ DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI, DebugLocTracker &DebugLocInfo); - /// isInlinedFnStart - Return true if FSI is starting an inlined function. - bool isInlinedFnStart(DbgFuncStartInst &FSI, const Function *CurrentFn); - - /// isInlinedFnEnd - Return true if REI is ending an inlined function. - bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn); - /// DebugInfoFinder - This object collects DebugInfo from a module. class DebugInfoFinder { public: Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original) +++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Tue Nov 10 17:06:00 2009 @@ -104,14 +104,8 @@ /// be emitted. bool ShouldEmitDwarfDebug() const; - //// RecordInlinedFnStart - Indicate the start of a inlined function. - unsigned RecordInlinedFnStart(DISubprogram SP, DICompileUnit CU, - unsigned Line, unsigned Col); - - /// RecordInlinedFnEnd - Indicate the end of inlined subroutine. - unsigned RecordInlinedFnEnd(DISubprogram SP); - void SetDbgScopeBeginLabels(const MachineInstr *MI, unsigned L); - void SetDbgScopeEndLabels(const MachineInstr *MI, unsigned L); + void BeginScope(const MachineInstr *MI, unsigned Label); + void EndScope(const MachineInstr *MI); }; } // end llvm namespace Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Nov 10 17:06:00 2009 @@ -150,7 +150,8 @@ public: static char ID; // Pass identification, replacement for typeid - typedef SmallVector< std::pair, unsigned>, 4 > + typedef std::pair > UnsignedAndMDNodePair; + typedef SmallVector< std::pair, UnsignedAndMDNodePair>, 4> VariableDbgInfoMapTy; VariableDbgInfoMapTy VariableDbgInfo; @@ -336,8 +337,8 @@ /// setVariableDbgInfo - Collect information used to emit debugging information /// of a variable. - void setVariableDbgInfo(MDNode *N, unsigned S) { - VariableDbgInfo.push_back(std::make_pair(N, S)); + void setVariableDbgInfo(MDNode *N, unsigned Slot, MDNode *Scope) { + VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Scope))); } VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; } Modified: llvm/trunk/include/llvm/Transforms/Utils/Cloning.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Cloning.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Cloning.h Tue Nov 10 17:06:00 2009 @@ -24,6 +24,7 @@ class Module; class Function; +class Instruction; class Pass; class LPPassManager; class BasicBlock; @@ -154,7 +155,8 @@ SmallVectorImpl &Returns, const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = 0, - const TargetData *TD = 0); + const TargetData *TD = 0, + Instruction *TheCall = 0); /// InlineFunction - This function inlines the called function into the basic /// block of the caller. This returns false if it is not possible to inline Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Nov 10 17:06:00 2009 @@ -1487,22 +1487,4 @@ return DebugLoc::get(Id); } - - /// isInlinedFnStart - Return true if FSI is starting an inlined function. - bool isInlinedFnStart(DbgFuncStartInst &FSI, const Function *CurrentFn) { - DISubprogram Subprogram(cast(FSI.getSubprogram())); - if (Subprogram.describes(CurrentFn)) - return false; - - return true; - } - - /// isInlinedFnEnd - Return true if REI is ending an inlined function. - bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn) { - DISubprogram Subprogram(cast(REI.getContext())); - if (Subprogram.isNull() || Subprogram.describes(CurrentFn)) - return false; - - return true; - } } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Nov 10 17:06:00 2009 @@ -1357,32 +1357,31 @@ /// instruction's DebugLoc. void AsmPrinter::processDebugLoc(const MachineInstr *MI, bool BeforePrintingInsn) { - if (!MAI || !DW) + if (!MAI || !DW || !MAI->doesSupportDebugInformation() + || !DW->ShouldEmitDwarfDebug()) return; DebugLoc DL = MI->getDebugLoc(); - if (MAI->doesSupportDebugInformation() && DW->ShouldEmitDwarfDebug()) { - if (!DL.isUnknown()) { - DebugLocTuple CurDLT = MF->getDebugLocTuple(DL); - if (BeforePrintingInsn) { - if (CurDLT.Scope != 0 && PrevDLT != CurDLT) { - unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col, - CurDLT.Scope); - printLabel(L); - O << '\n'; -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - DW->SetDbgScopeBeginLabels(MI, L); -#endif - } else { -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - DW->SetDbgScopeEndLabels(MI, 0); -#endif - } - } + if (DL.isUnknown()) + return; + DebugLocTuple CurDLT = MF->getDebugLocTuple(DL); + if (CurDLT.Scope == 0) + return; + + if (BeforePrintingInsn) { + if (CurDLT != PrevDLT) { + unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col, + CurDLT.Scope); + printLabel(L); + DW->BeginScope(MI, L); PrevDLT = CurDLT; } + } else { + // After printing instruction + DW->EndScope(MI); } } + /// printInlineAsm - This method formats and prints the specified machine /// instruction that is an inline asm. void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 10 17:06:00 2009 @@ -127,15 +127,19 @@ class DbgVariable { DIVariable Var; // Variable Descriptor. unsigned FrameIndex; // Variable frame index. - bool InlinedFnVar; // Variable for an inlined function. + DbgVariable *AbstractVar; // Abstract variable for this variable. + DIE *TheDIE; public: - DbgVariable(DIVariable V, unsigned I, bool IFV) - : Var(V), FrameIndex(I), InlinedFnVar(IFV) {} + DbgVariable(DIVariable V, unsigned I) + : Var(V), FrameIndex(I), AbstractVar(0), TheDIE(0) {} // Accessors. - DIVariable getVariable() const { return Var; } - unsigned getFrameIndex() const { return FrameIndex; } - bool isInlinedFnVar() const { return InlinedFnVar; } + DIVariable getVariable() const { return Var; } + unsigned getFrameIndex() const { return FrameIndex; } + void setAbstractVariable(DbgVariable *V) { AbstractVar = V; } + DbgVariable *getAbstractVariable() const { return AbstractVar; } + void setDIE(DIE *D) { TheDIE = D; } + DIE *getDIE() const { return TheDIE; } }; //===----------------------------------------------------------------------===// @@ -144,44 +148,46 @@ class DbgConcreteScope; class DbgScope { DbgScope *Parent; // Parent to this scope. - DIDescriptor Desc; // Debug info descriptor for scope. - // FIXME use WeakVH for Desc. - WeakVH InlinedAt; // If this scope represents inlined - // function body then this is the location - // where this body is inlined. + DIDescriptor Desc; // Debug info descriptor for scope. + WeakVH InlinedAtLocation; // Location at which scope is inlined. + bool AbstractScope; // Abstract Scope unsigned StartLabelID; // Label ID of the beginning of scope. unsigned EndLabelID; // Label ID of the end of scope. const MachineInstr *LastInsn; // Last instruction of this scope. const MachineInstr *FirstInsn; // First instruction of this scope. SmallVector Scopes; // Scopes defined in scope. SmallVector Variables;// Variables declared in scope. - SmallVector ConcreteInsts;// Concrete insts of funcs. // Private state for dump() mutable unsigned IndentLevel; public: DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0) - : Parent(P), Desc(D), InlinedAt(I), StartLabelID(0), EndLabelID(0), + : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(false), + StartLabelID(0), EndLabelID(0), LastInsn(0), FirstInsn(0), IndentLevel(0) {} virtual ~DbgScope(); // Accessors. DbgScope *getParent() const { return Parent; } + void setParent(DbgScope *P) { Parent = P; } DIDescriptor getDesc() const { return Desc; } - MDNode *getInlinedAt() const { - return dyn_cast_or_null(InlinedAt); + MDNode *getInlinedAt() const { + return dyn_cast_or_null(InlinedAtLocation); } + MDNode *getScopeNode() const { return Desc.getNode(); } unsigned getStartLabelID() const { return StartLabelID; } unsigned getEndLabelID() const { return EndLabelID; } SmallVector &getScopes() { return Scopes; } SmallVector &getVariables() { return Variables; } - SmallVector &getConcreteInsts() { return ConcreteInsts; } void setStartLabelID(unsigned S) { StartLabelID = S; } void setEndLabelID(unsigned E) { EndLabelID = E; } void setLastInsn(const MachineInstr *MI) { LastInsn = MI; } const MachineInstr *getLastInsn() { return LastInsn; } void setFirstInsn(const MachineInstr *MI) { FirstInsn = MI; } + void setAbstractScope() { AbstractScope = true; } + bool isAbstractScope() const { return AbstractScope; } const MachineInstr *getFirstInsn() { return FirstInsn; } + /// AddScope - Add a scope to the scope. /// void AddScope(DbgScope *S) { Scopes.push_back(S); } @@ -190,10 +196,6 @@ /// void AddVariable(DbgVariable *V) { Variables.push_back(V); } - /// AddConcreteInst - Add a concrete instance to the scope. - /// - void AddConcreteInst(DbgConcreteScope *C) { ConcreteInsts.push_back(C); } - void FixInstructionMarkers() { assert (getFirstInsn() && "First instruction is missing!"); if (getLastInsn()) @@ -218,11 +220,15 @@ void DbgScope::dump() const { raw_ostream &err = errs(); err.indent(IndentLevel); - Desc.dump(); + MDNode *N = Desc.getNode(); + N->dump(); err << " [" << StartLabelID << ", " << EndLabelID << "]\n"; + if (AbstractScope) + err << "Abstract Scope\n"; IndentLevel += 2; - + if (!Scopes.empty()) + err << "Children ...\n"; for (unsigned i = 0, e = Scopes.size(); i != e; ++i) if (Scopes[i] != this) Scopes[i]->dump(); @@ -251,8 +257,6 @@ delete Scopes[i]; for (unsigned j = 0, M = Variables.size(); j < M; ++j) delete Variables[j]; - for (unsigned k = 0, O = ConcreteInsts.size(); k < O; ++k) - delete ConcreteInsts[k]; } } // end llvm namespace @@ -262,7 +266,7 @@ AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(), ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionSourceLines(), didInitial(false), shouldEmit(false), - FunctionDbgScope(0), DebugTimer(0) { + CurrentFnDbgScope(0), DebugTimer(0) { if (TimePassesIsEnabled) DebugTimer = new Timer("Dwarf Debug Writer", getDwarfTimerGroup()); @@ -271,11 +275,6 @@ for (unsigned j = 0, M = Values.size(); j < M; ++j) delete Values[j]; - for (DenseMap::iterator - I = AbstractInstanceRootMap.begin(), - E = AbstractInstanceRootMap.end(); I != E;++I) - delete I->second; - delete DebugTimer; } @@ -1237,9 +1236,6 @@ } } - if (!SP.isLocalToUnit() && !IsInlined) - AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - // DW_TAG_inlined_subroutine may refer to this DIE. DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getNode()); Slot = SPDie; @@ -1287,81 +1283,109 @@ AddSourceLine(VariableDie, &VD); // Add variable type. - // FIXME: isBlockByrefVariable should be reformulated in terms of complex addresses instead. + // FIXME: isBlockByrefVariable should be reformulated in terms of complex + // addresses instead. if (VD.isBlockByrefVariable()) AddType(Unit, VariableDie, GetBlockByrefType(VD.getType(), Name)); else AddType(Unit, VariableDie, VD.getType()); // Add variable address. - if (!DV->isInlinedFnVar()) { - // Variables for abstract instances of inlined functions don't get a - // location. - MachineLocation Location; - Location.set(RI->getFrameRegister(*MF), - RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); - - - if (VD.hasComplexAddress()) - AddComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location); - else if (VD.isBlockByrefVariable()) - AddBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location); - else - AddAddress(VariableDie, dwarf::DW_AT_location, Location); - } + // Variables for abstract instances of inlined functions don't get a + // location. + MachineLocation Location; + Location.set(RI->getFrameRegister(*MF), + RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); + + + if (VD.hasComplexAddress()) + AddComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location); + else if (VD.isBlockByrefVariable()) + AddBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location); + else + AddAddress(VariableDie, dwarf::DW_AT_location, Location); return VariableDie; } -/// getOrCreateScope - Returns the scope associated with the given descriptor. -/// -DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI, - MDNode *InlinedAt) { - ValueMap::iterator VI = DbgScopeMap.find(N); - if (VI != DbgScopeMap.end()) - return VI->second; +/// getUpdatedDbgScope - Find or create DbgScope assicated with the instruction. +/// Initialize scope and update scope hierarchy. +DbgScope *DwarfDebug::getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, + MDNode *InlinedAt) { + assert (N && "Invalid Scope encoding!"); + assert (MI && "Missing machine instruction!"); + bool GetConcreteScope = (MI && InlinedAt); - DbgScope *Parent = NULL; + DbgScope *NScope = NULL; + + if (InlinedAt) + NScope = DbgScopeMap.lookup(InlinedAt); + else + NScope = DbgScopeMap.lookup(N); + assert (NScope && "Unable to find working scope!"); + + if (NScope->getFirstInsn()) + return NScope; - if (InlinedAt) { + DbgScope *Parent = NULL; + if (GetConcreteScope) { DILocation IL(InlinedAt); - assert (!IL.isNull() && "Invalid InlindAt location!"); - ValueMap::iterator DSI = - DbgScopeMap.find(IL.getScope().getNode()); - assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt scope!"); - Parent = DSI->second; - } else { - DIDescriptor Scope(N); - if (Scope.isCompileUnit()) { - return NULL; - } else if (Scope.isSubprogram()) { - DISubprogram SP(N); - DIDescriptor ParentDesc = SP.getContext(); - if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) - Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); - } else if (Scope.isLexicalBlock()) { - DILexicalBlock DB(N); - DIDescriptor ParentDesc = DB.getContext(); - if (!ParentDesc.isNull()) - Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); - } else - assert (0 && "Unexpected scope info"); + Parent = getUpdatedDbgScope(IL.getScope().getNode(), MI, + IL.getOrigLocation().getNode()); + assert (Parent && "Unable to find Parent scope!"); + NScope->setParent(Parent); + Parent->AddScope(NScope); + } else if (DIDescriptor(N).isLexicalBlock()) { + DILexicalBlock DB(N); + if (!DB.getContext().isNull()) { + Parent = getUpdatedDbgScope(DB.getContext().getNode(), MI, InlinedAt); + NScope->setParent(Parent); + Parent->AddScope(NScope); + } } - DbgScope *NScope = new DbgScope(Parent, DIDescriptor(N), InlinedAt); NScope->setFirstInsn(MI); - if (Parent) - Parent->AddScope(NScope); - else - // First function is top level function. - if (!FunctionDbgScope) - FunctionDbgScope = NScope; + if (!Parent && !InlinedAt) { + assert (!CurrentFnDbgScope && "Unexpected function scope!"); + CurrentFnDbgScope = NScope; + } + + if (GetConcreteScope) { + ConcreteScopes[InlinedAt] = NScope; + getOrCreateAbstractScope(N); + } - DbgScopeMap.insert(std::make_pair(N, NScope)); return NScope; } +DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) { + assert (N && "Invalid Scope encoding!"); + + DbgScope *AScope = AbstractScopes.lookup(N); + if (AScope) + return AScope; + + DbgScope *Parent = NULL; + + DIDescriptor Scope(N); + if (Scope.isLexicalBlock()) { + DILexicalBlock DB(N); + DIDescriptor ParentDesc = DB.getContext(); + if (!ParentDesc.isNull()) + Parent = getOrCreateAbstractScope(ParentDesc.getNode()); + } + + AScope = new DbgScope(Parent, DIDescriptor(N), NULL); + + if (Parent) + Parent->AddScope(AScope); + AScope->setAbstractScope(); + AbstractScopes[N] = AScope; + if (DIDescriptor(N).isSubprogram()) + AbstractScopesList.push_back(AScope); + return AScope; +} /// getOrCreateScope - Returns the scope associated with the given descriptor. /// FIXME - Remove this method. @@ -1372,12 +1396,6 @@ DbgScope *Parent = NULL; DILexicalBlock Block(N); - // Don't create a new scope if we already created one for an inlined function. - DenseMap::iterator - II = AbstractInstanceRootMap.find(N); - if (II != AbstractInstanceRootMap.end()) - return LexicalScopeStack.back(); - if (!Block.isNull()) { DIDescriptor ParentDesc = Block.getContext(); Parent = @@ -1390,13 +1408,241 @@ Parent->AddScope(Slot); else // First function is top level function. - FunctionDbgScope = Slot; + CurrentFnDbgScope = Slot; return Slot; } +static DISubprogram getDISubprogram(MDNode *N) { + + DIDescriptor D(N); + if (D.isNull()) + return DISubprogram(); + + if (D.isCompileUnit()) + return DISubprogram(); + + if (D.isSubprogram()) + return DISubprogram(N); + + if (D.isLexicalBlock()) + return getDISubprogram(DILexicalBlock(N).getContext().getNode()); + + llvm_unreachable("Unexpected Descriptor!"); +} + +DIE *DwarfDebug::UpdateSubprogramScopeDIE(MDNode *SPNode) { + + DIE *SPDie = ModuleCU->getDieMapSlotFor(SPNode); + assert (SPDie && "Unable to find subprogram DIE!"); + AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + DWLabel("func_begin", SubprogramCount)); + AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, + DWLabel("func_end", SubprogramCount)); + MachineLocation Location(RI->getFrameRegister(*MF)); + AddAddress(SPDie, dwarf::DW_AT_frame_base, Location); + + if (!DISubprogram(SPNode).isLocalToUnit()) + AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); + + // If there are global variables at this scope then add their dies. + for (SmallVector::iterator SGI = ScopedGVs.begin(), + SGE = ScopedGVs.end(); SGI != SGE; ++SGI) { + MDNode *N = dyn_cast_or_null(*SGI); + if (!N) continue; + DIGlobalVariable GV(N); + if (GV.getContext().getNode() == SPNode) { + DIE *ScopedGVDie = CreateGlobalVariableDIE(ModuleCU, GV); + SPDie->AddChild(ScopedGVDie); + } + } + return SPDie; +} + +DIE *DwarfDebug::ConstructLexicalScopeDIE(DbgScope *Scope) { + unsigned StartID = MMI->MappedLabel(Scope->getStartLabelID()); + unsigned EndID = MMI->MappedLabel(Scope->getEndLabelID()); + + // Ignore empty scopes. + if (StartID == EndID && StartID != 0) + return NULL; + + DIE *ScopeDIE = new DIE(dwarf::DW_TAG_lexical_block); + if (Scope->isAbstractScope()) + return ScopeDIE; + + AddLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + StartID ? + DWLabel("label", StartID) + : DWLabel("func_begin", SubprogramCount)); + AddLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, + EndID ? + DWLabel("label", EndID) + : DWLabel("func_end", SubprogramCount)); + + + + return ScopeDIE; +} + +DIE *DwarfDebug::ConstructInlinedScopeDIE(DbgScope *Scope) { + unsigned StartID = MMI->MappedLabel(Scope->getStartLabelID()); + unsigned EndID = MMI->MappedLabel(Scope->getEndLabelID()); + assert (StartID && "Invalid starting label for an inlined scope!"); + assert (EndID && "Invalid end label for an inlined scope!"); + // Ignore empty scopes. + if (StartID == EndID && StartID != 0) + return NULL; + + DIScope DS(Scope->getScopeNode()); + if (DS.isNull()) + return NULL; + DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); + + DISubprogram InlinedSP = getDISubprogram(DS.getNode()); + DIE *&OriginDIE = ModuleCU->getDieMapSlotFor(InlinedSP.getNode()); + assert (OriginDIE && "Unable to find Origin DIE!"); + AddDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, + dwarf::DW_FORM_ref4, OriginDIE); + + AddLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + DWLabel("label", StartID)); + AddLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, + DWLabel("label", EndID)); + + InlinedSubprogramDIEs.insert(OriginDIE); + + // Track the start label for this inlined function. + ValueMap >::iterator + I = InlineInfo.find(InlinedSP.getNode()); + + if (I == InlineInfo.end()) { + InlineInfo[InlinedSP.getNode()].push_back(std::make_pair(StartID, ScopeDIE)); + InlinedSPNodes.push_back(InlinedSP.getNode()); + } else + I->second.push_back(std::make_pair(StartID, ScopeDIE)); + + StringPool.insert(InlinedSP.getName()); + StringPool.insert(InlinedSP.getLinkageName()); + DILocation DL(Scope->getInlinedAt()); + AddUInt(ScopeDIE, dwarf::DW_AT_call_file, 0, ModuleCU->getID()); + AddUInt(ScopeDIE, dwarf::DW_AT_call_line, 0, DL.getLineNumber()); + + return ScopeDIE; +} + +DIE *DwarfDebug::ConstructVariableDIE(DbgVariable *DV, + DbgScope *Scope, CompileUnit *Unit) { + // Get the descriptor. + const DIVariable &VD = DV->getVariable(); + + // Translate tag to proper Dwarf tag. The result variable is dropped for + // now. + unsigned Tag; + switch (VD.getTag()) { + case dwarf::DW_TAG_return_variable: + return NULL; + case dwarf::DW_TAG_arg_variable: + Tag = dwarf::DW_TAG_formal_parameter; + break; + case dwarf::DW_TAG_auto_variable: // fall thru + default: + Tag = dwarf::DW_TAG_variable; + break; + } + + // Define variable debug information entry. + DIE *VariableDie = new DIE(Tag); + + + DIE *AbsDIE = NULL; + if (DbgVariable *AV = DV->getAbstractVariable()) + AbsDIE = AV->getDIE(); + + if (AbsDIE) { + DIScope DS(Scope->getScopeNode()); + DISubprogram InlinedSP = getDISubprogram(DS.getNode()); + DIE *&OriginSPDIE = ModuleCU->getDieMapSlotFor(InlinedSP.getNode()); + assert (OriginSPDIE && "Unable to find Origin DIE for the SP!"); + DIE *AbsDIE = DV->getAbstractVariable()->getDIE(); + assert (AbsDIE && "Unable to find Origin DIE for the Variable!"); + AddDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin, + dwarf::DW_FORM_ref4, AbsDIE); + } + else { + const char *Name = VD.getName(); + AddString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); + AddSourceLine(VariableDie, &VD); + + // Add variable type. + // FIXME: isBlockByrefVariable should be reformulated in terms of complex + // addresses instead. + if (VD.isBlockByrefVariable()) + AddType(Unit, VariableDie, GetBlockByrefType(VD.getType(), Name)); + else + AddType(Unit, VariableDie, VD.getType()); + } + + // Add variable address. + if (!Scope->isAbstractScope()) { + MachineLocation Location; + Location.set(RI->getFrameRegister(*MF), + RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); + + + if (VD.hasComplexAddress()) + AddComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location); + else if (VD.isBlockByrefVariable()) + AddBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location); + else + AddAddress(VariableDie, dwarf::DW_AT_location, Location); + } + DV->setDIE(VariableDie); + return VariableDie; + +} +DIE *DwarfDebug::ConstructScopeDIE(DbgScope *Scope) { + if (!Scope) + return NULL; + DIScope DS(Scope->getScopeNode()); + if (DS.isNull()) + return NULL; + + DIE *ScopeDIE = NULL; + if (Scope->getInlinedAt()) + ScopeDIE = ConstructInlinedScopeDIE(Scope); + else if (DS.isSubprogram()) { + if (Scope->isAbstractScope()) + ScopeDIE = ModuleCU->getDieMapSlotFor(DS.getNode()); + else + ScopeDIE = UpdateSubprogramScopeDIE(DS.getNode()); + } + else { + ScopeDIE = ConstructLexicalScopeDIE(Scope); + if (!ScopeDIE) return NULL; + } + + // Add variables to scope. + SmallVector &Variables = Scope->getVariables(); + for (unsigned i = 0, N = Variables.size(); i < N; ++i) { + DIE *VariableDIE = ConstructVariableDIE(Variables[i], Scope, ModuleCU); + if (VariableDIE) + ScopeDIE->AddChild(VariableDIE); + } + + // Add nested scopes. + SmallVector &Scopes = Scope->getScopes(); + for (unsigned j = 0, M = Scopes.size(); j < M; ++j) { + // Define the Scope debug information entry. + DIE *NestedDIE = ConstructScopeDIE(Scopes[j]); + if (NestedDIE) + ScopeDIE->AddChild(NestedDIE); + } + return ScopeDIE; +} + /// ConstructDbgScope - Construct the components of a scope. -/// +/// FIXME: Remove void DwarfDebug::ConstructDbgScope(DbgScope *ParentScope, unsigned ParentStartID, unsigned ParentEndID, @@ -1408,34 +1654,6 @@ if (VariableDie) ParentDie->AddChild(VariableDie); } - // Add concrete instances to scope. - SmallVector &ConcreteInsts = - ParentScope->getConcreteInsts(); - for (unsigned i = 0, N = ConcreteInsts.size(); i < N; ++i) { - DbgConcreteScope *ConcreteInst = ConcreteInsts[i]; - DIE *Die = ConcreteInst->getDie(); - - unsigned StartID = ConcreteInst->getStartLabelID(); - unsigned EndID = ConcreteInst->getEndLabelID(); - - // Add the scope bounds. - if (StartID) - AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("label", StartID)); - else - AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("func_begin", SubprogramCount)); - - if (EndID) - AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("label", EndID)); - else - AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("func_end", SubprogramCount)); - - ParentDie->AddChild(Die); - } - // Add nested scopes. SmallVector &Scopes = ParentScope->getScopes(); for (unsigned j = 0, M = Scopes.size(); j < M; ++j) { @@ -1450,8 +1668,7 @@ // Do not ignore inlined scopes even if they don't have any variables or // scopes. - if (Scope->getScopes().empty() && Scope->getVariables().empty() && - Scope->getConcreteInsts().empty()) + if (Scope->getScopes().empty() && Scope->getVariables().empty()) continue; if (StartID == ParentStartID && EndID == ParentEndID) { @@ -1482,9 +1699,9 @@ } } -/// ConstructFunctionDbgScope - Construct the scope for the subprogram. -/// -void DwarfDebug::ConstructFunctionDbgScope(DbgScope *RootScope, +/// ConstructCurrentFnDbgScope - Construct the scope for the subprogram. +/// FIXME: Remove +void DwarfDebug::ConstructCurrentFnDbgScope(DbgScope *RootScope, bool AbstractScope) { // Exit if there is no root scope. if (!RootScope) return; @@ -1529,7 +1746,7 @@ } /// ConstructDefaultDbgScope - Construct a default scope for the subprogram. -/// +/// FIXME: Remove void DwarfDebug::ConstructDefaultDbgScope(MachineFunction *MF) { StringMap &Globals = ModuleCU->getGlobals(); StringMap::iterator GI = Globals.find(MF->getFunction()->getName()); @@ -1715,7 +1932,7 @@ ConstructGlobalVariableDIE(*I); } - // Create DIEs for each of the externally visible subprograms. + // Create DIEs for each subprogram. for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(), E = DbgFinder.subprogram_end(); I != E; ++I) ConstructSubprogram(*I); @@ -1759,6 +1976,13 @@ if (TimePassesIsEnabled) DebugTimer->startTimer(); + // Attach DW_AT_inline attribute with inlined subprogram DIEs. + for (SmallPtrSet::iterator AI = InlinedSubprogramDIEs.begin(), + AE = InlinedSubprogramDIEs.end(); AI != AE; ++AI) { + DIE *ISP = *AI; + AddUInt(ISP, dwarf::DW_AT_inline, 0, dwarf::DW_INL_inlined); + } + // Standard sections final addresses. Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getTextSection()); EmitLabel("text_end", 0); @@ -1816,55 +2040,98 @@ DebugTimer->stopTimer(); } +/// findAbstractVariable - Find abstract variable, if any, associated with Var. +DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var, unsigned FrameIdx, + DILocation &ScopeLoc) { + + DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode()); + if (AbsDbgVariable) + return AbsDbgVariable; + + DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope().getNode()); + if (!Scope) + return NULL; + + AbsDbgVariable = new DbgVariable(Var, FrameIdx); + Scope->AddVariable(AbsDbgVariable); + AbstractVariables[Var.getNode()] = AbsDbgVariable; + return AbsDbgVariable; +} + /// CollectVariableInfo - Populate DbgScope entries with variables' info. void DwarfDebug::CollectVariableInfo() { if (!MMI) return; + MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo(); for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(), VE = VMap.end(); VI != VE; ++VI) { MetadataBase *MB = VI->first; MDNode *Var = dyn_cast_or_null(MB); + if (!Var) continue; DIVariable DV (Var); - if (DV.isNull()) continue; - unsigned VSlot = VI->second; - DbgScope *Scope = NULL; - ValueMap::iterator DSI = - DbgScopeMap.find(DV.getContext().getNode()); - if (DSI != DbgScopeMap.end()) - Scope = DSI->second; - else - // There is not any instruction assocated with this scope, so get - // a new scope. - Scope = getDbgScope(DV.getContext().getNode(), - NULL /* Not an instruction */, - NULL /* Not inlined */); + std::pair< unsigned, MDNode *> VP = VI->second; + DILocation ScopeLoc(VP.second); + + DbgScope *Scope = + ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode()); + if (!Scope) + Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode()); assert (Scope && "Unable to find variable scope!"); - Scope->AddVariable(new DbgVariable(DV, VSlot, false)); + + DbgVariable *RegVar = new DbgVariable(DV, VP.first); + Scope->AddVariable(RegVar); + if (DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.first, ScopeLoc)) + RegVar->setAbstractVariable(AbsDbgVariable); } } -/// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that -/// start with this machine instruction. -void DwarfDebug::SetDbgScopeBeginLabels(const MachineInstr *MI, unsigned Label) { +/// BeginScope - Process beginning of a scope starting at Label. +void DwarfDebug::BeginScope(const MachineInstr *MI, unsigned Label) { InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI); if (I == DbgScopeBeginMap.end()) return; - SmallVector &SD = I->second; - for (SmallVector::iterator SDI = SD.begin(), SDE = SD.end(); + ScopeVector &SD = DbgScopeBeginMap[MI]; + for (ScopeVector::iterator SDI = SD.begin(), SDE = SD.end(); SDI != SDE; ++SDI) (*SDI)->setStartLabelID(Label); } -/// SetDbgScopeEndLabels - Update DbgScope end labels for the scopes that -/// end with this machine instruction. -void DwarfDebug::SetDbgScopeEndLabels(const MachineInstr *MI, unsigned Label) { +/// EndScope - Process end of a scope. +void DwarfDebug::EndScope(const MachineInstr *MI) { InsnToDbgScopeMapTy::iterator I = DbgScopeEndMap.find(MI); if (I == DbgScopeEndMap.end()) return; + + unsigned Label = MMI->NextLabelID(); + Asm->printLabel(Label); + SmallVector &SD = I->second; for (SmallVector::iterator SDI = SD.begin(), SDE = SD.end(); SDI != SDE; ++SDI) (*SDI)->setEndLabelID(Label); + return; +} + +/// createDbgScope - Create DbgScope for the scope. +void DwarfDebug::createDbgScope(MDNode *Scope, MDNode *InlinedAt) { + + if (!InlinedAt) { + DbgScope *WScope = DbgScopeMap.lookup(Scope); + if (WScope) + return; + WScope = new DbgScope(NULL, DIDescriptor(Scope), NULL); + DbgScopeMap.insert(std::make_pair(Scope, WScope)); + return; + } + + DbgScope *WScope = DbgScopeMap.lookup(InlinedAt); + if (WScope) + return; + + WScope = new DbgScope(NULL, DIDescriptor(Scope), InlinedAt); + DbgScopeMap.insert(std::make_pair(InlinedAt, WScope)); + DILocation DL(InlinedAt); + createDbgScope(DL.getScope().getNode(), DL.getOrigLocation().getNode()); } /// ExtractScopeInformation - Scan machine instructions in this function @@ -1875,26 +2142,41 @@ if (!DbgScopeMap.empty()) return false; - // Scan each instruction and create scopes. + // Scan each instruction and create scopes. First build working set of scopes. for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); II != IE; ++II) { const MachineInstr *MInsn = II; DebugLoc DL = MInsn->getDebugLoc(); - if (DL.isUnknown()) - continue; + if (DL.isUnknown()) continue; DebugLocTuple DLT = MF->getDebugLocTuple(DL); - if (!DLT.Scope) - continue; + if (!DLT.Scope) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - DIDescriptor D(DLT.Scope); - if (!D.isCompileUnit()) { - DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc); - Scope->setLastInsn(MInsn); - } + if (DIDescriptor(DLT.Scope).isCompileUnit()) continue; + createDbgScope(DLT.Scope, DLT.InlinedAtLoc); + } + } + + + // Build scope hierarchy using working set of scopes. + for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); + I != E; ++I) { + for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); + II != IE; ++II) { + const MachineInstr *MInsn = II; + DebugLoc DL = MInsn->getDebugLoc(); + if (DL.isUnknown()) continue; + DebugLocTuple DLT = MF->getDebugLocTuple(DL); + if (!DLT.Scope) continue; + // There is no need to create another DIE for compile unit. For all + // other scopes, create one DbgScope now. This will be translated + // into a scope DIE at the end. + if (DIDescriptor(DLT.Scope).isCompileUnit()) continue; + DbgScope *Scope = getUpdatedDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc); + Scope->setLastInsn(MInsn); } } @@ -1902,8 +2184,8 @@ // last instruction as this scope's last instrunction. for (ValueMap::iterator DI = DbgScopeMap.begin(), DE = DbgScopeMap.end(); DI != DE; ++DI) { - DbgScope *S = DI->second; - if (!S) continue; + if (DI->second->isAbstractScope()) + continue; assert (DI->second->getFirstInsn() && "Invalid first instruction!"); DI->second->FixInstructionMarkers(); assert (DI->second->getLastInsn() && "Invalid last instruction!"); @@ -1916,7 +2198,8 @@ for (ValueMap::iterator DI = DbgScopeMap.begin(), DE = DbgScopeMap.end(); DI != DE; ++DI) { DbgScope *S = DI->second; - if (!S) continue; + if (S->isAbstractScope()) + continue; const MachineInstr *MI = S->getFirstInsn(); assert (MI && "DbgScope does not have first instruction!"); @@ -1924,8 +2207,7 @@ if (IDI != DbgScopeBeginMap.end()) IDI->second.push_back(S); else - DbgScopeBeginMap.insert(std::make_pair(MI, - SmallVector(2, S))); + DbgScopeBeginMap[MI].push_back(S); MI = S->getLastInsn(); assert (MI && "DbgScope does not have last instruction!"); @@ -1933,31 +2215,12 @@ if (IDI != DbgScopeEndMap.end()) IDI->second.push_back(S); else - DbgScopeEndMap.insert(std::make_pair(MI, - SmallVector(2, S))); + DbgScopeEndMap[MI].push_back(S); } return !DbgScopeMap.empty(); } -static DISubprogram getDISubprogram(MDNode *N) { - - DIDescriptor D(N); - if (D.isNull()) - return DISubprogram(); - - if (D.isCompileUnit()) - return DISubprogram(); - - if (D.isSubprogram()) - return DISubprogram(N); - - if (D.isLexicalBlock()) - return getDISubprogram(DILexicalBlock(N).getContext().getNode()); - - llvm_unreachable("Unexpected Descriptor!"); -} - /// BeginFunction - Gather pre-function debug information. Assumes being /// emitted immediately after the function entry point. void DwarfDebug::BeginFunction(MachineFunction *MF) { @@ -2034,15 +2297,10 @@ Lines.begin(), Lines.end()); } - // Construct the DbgScope for abstract instances. - for (SmallVector::iterator - I = AbstractInstanceRootList.begin(), - E = AbstractInstanceRootList.end(); I != E; ++I) - ConstructFunctionDbgScope(*I); - +#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN // Construct scopes for subprogram. - if (FunctionDbgScope) - ConstructFunctionDbgScope(FunctionDbgScope); + if (CurrentFnDbgScope) + ConstructCurrentFnDbgScope(CurrentFnDbgScope); else // FIXME: This is wrong. We are essentially getting past a problem with // debug information not being able to handle unreachable blocks that have @@ -2053,22 +2311,25 @@ // desirable. And a better way of handling this (and all of the debugging // information) needs to be explored. ConstructDefaultDbgScope(MF); +#else + // Construct abstract scopes. + for (SmallVector::iterator AI = AbstractScopesList.begin(), + AE = AbstractScopesList.end(); AI != AE; ++AI) + ConstructScopeDIE(*AI); + ConstructScopeDIE(CurrentFnDbgScope); +#endif DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount, MMI->getFrameMoves())); // Clear debug info - if (FunctionDbgScope) { - delete FunctionDbgScope; + if (CurrentFnDbgScope) { + CurrentFnDbgScope = NULL; DbgScopeMap.clear(); DbgScopeBeginMap.clear(); DbgScopeEndMap.clear(); - DbgAbstractScopeMap.clear(); - DbgConcreteScopeMap.clear(); - FunctionDbgScope = NULL; - LexicalScopeStack.clear(); - AbstractInstanceRootList.clear(); - AbstractInstanceRootMap.clear(); + ConcreteScopes.clear(); + AbstractScopesList.clear(); } Lines.clear(); @@ -2143,7 +2404,6 @@ DbgScope *Scope = getOrCreateScope(N); unsigned ID = MMI->NextLabelID(); if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID); - LexicalScopeStack.push_back(Scope); if (TimePassesIsEnabled) DebugTimer->stopTimer(); @@ -2159,12 +2419,6 @@ DbgScope *Scope = getOrCreateScope(N); unsigned ID = MMI->NextLabelID(); Scope->setEndLabelID(ID); - // FIXME : region.end() may not be in the last basic block. - // For now, do not pop last lexical scope because next basic - // block may start new inlined function's body. - unsigned LSSize = LexicalScopeStack.size(); - if (LSSize != 0 && LSSize != 1) - LexicalScopeStack.pop_back(); if (TimePassesIsEnabled) DebugTimer->stopTimer(); @@ -2179,157 +2433,22 @@ DIDescriptor Desc(N); DbgScope *Scope = NULL; - bool InlinedFnVar = false; if (Desc.getTag() == dwarf::DW_TAG_variable) Scope = getOrCreateScope(DIGlobalVariable(N).getContext().getNode()); else { - bool InlinedVar = false; MDNode *Context = DIVariable(N).getContext().getNode(); - DISubprogram SP(Context); - if (!SP.isNull()) { - // SP is inserted into DbgAbstractScopeMap when inlined function - // start was recorded by RecordInlineFnStart. - ValueMap::iterator - I = DbgAbstractScopeMap.find(SP.getNode()); - if (I != DbgAbstractScopeMap.end()) { - InlinedVar = true; - Scope = I->second; - } - } - if (!InlinedVar) - Scope = getOrCreateScope(Context); + Scope = getOrCreateScope(Context); } assert(Scope && "Unable to find the variable's scope"); - DbgVariable *DV = new DbgVariable(DIVariable(N), FrameIndex, InlinedFnVar); + DbgVariable *DV = new DbgVariable(DIVariable(N), FrameIndex); Scope->AddVariable(DV); if (TimePassesIsEnabled) DebugTimer->stopTimer(); } -//// RecordInlinedFnStart - Indicate the start of inlined subroutine. -unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU, - unsigned Line, unsigned Col) { - unsigned LabelID = MMI->NextLabelID(); - - if (!MAI->doesDwarfUsesInlineInfoSection()) - return LabelID; - - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - MDNode *Node = SP.getNode(); - DenseMap::iterator - II = AbstractInstanceRootMap.find(Node); - - if (II == AbstractInstanceRootMap.end()) { - // Create an abstract instance entry for this inlined function if it doesn't - // already exist. - DbgScope *Scope = new DbgScope(NULL, DIDescriptor(Node)); - - // Get the compile unit context. - DIE *SPDie = ModuleCU->getDieMapSlotFor(Node); - if (!SPDie) - SPDie = CreateSubprogramDIE(ModuleCU, SP, false, true); - - // Mark as being inlined. This makes this subprogram entry an abstract - // instance root. - // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only - // that it's defined. That probably won't change in the future. However, - // this could be more elegant. - AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined); - - // Keep track of the abstract scope for this function. - DbgAbstractScopeMap[Node] = Scope; - - AbstractInstanceRootMap[Node] = Scope; - AbstractInstanceRootList.push_back(Scope); - } - - // Create a concrete inlined instance for this inlined function. - DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(Node)); - DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine); - ScopeDie->setAbstractCompileUnit(ModuleCU); - - DIE *Origin = ModuleCU->getDieMapSlotFor(Node); - AddDIEEntry(ScopeDie, dwarf::DW_AT_abstract_origin, - dwarf::DW_FORM_ref4, Origin); - AddUInt(ScopeDie, dwarf::DW_AT_call_file, 0, ModuleCU->getID()); - AddUInt(ScopeDie, dwarf::DW_AT_call_line, 0, Line); - AddUInt(ScopeDie, dwarf::DW_AT_call_column, 0, Col); - - ConcreteScope->setDie(ScopeDie); - ConcreteScope->setStartLabelID(LabelID); - MMI->RecordUsedDbgLabel(LabelID); - - LexicalScopeStack.back()->AddConcreteInst(ConcreteScope); - - // Keep track of the concrete scope that's inlined into this function. - ValueMap >::iterator - SI = DbgConcreteScopeMap.find(Node); - - if (SI == DbgConcreteScopeMap.end()) - DbgConcreteScopeMap[Node].push_back(ConcreteScope); - else - SI->second.push_back(ConcreteScope); - - // Track the start label for this inlined function. - ValueMap >::iterator - I = InlineInfo.find(Node); - - if (I == InlineInfo.end()) - InlineInfo[Node].push_back(LabelID); - else - I->second.push_back(LabelID); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return LabelID; -} - -/// RecordInlinedFnEnd - Indicate the end of inlined subroutine. -unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) { - if (!MAI->doesDwarfUsesInlineInfoSection()) - return 0; - - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - MDNode *Node = SP.getNode(); - ValueMap >::iterator - I = DbgConcreteScopeMap.find(Node); - - if (I == DbgConcreteScopeMap.end()) { - // FIXME: Can this situation actually happen? And if so, should it? - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return 0; - } - - SmallVector &Scopes = I->second; - if (Scopes.empty()) { - // Returned ID is 0 if this is unbalanced "end of inlined - // scope". This could happen if optimizer eats dbg intrinsics - // or "beginning of inlined scope" is not recoginized due to - // missing location info. In such cases, ignore this region.end. - return 0; - } - - DbgScope *Scope = Scopes.back(); Scopes.pop_back(); - unsigned ID = MMI->NextLabelID(); - MMI->RecordUsedDbgLabel(ID); - Scope->setEndLabelID(ID); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return ID; -} - //===----------------------------------------------------------------------===// // Emit Methods //===----------------------------------------------------------------------===// @@ -2475,10 +2594,7 @@ case dwarf::DW_AT_abstract_origin: { DIEEntry *E = cast(Values[i]); DIE *Origin = E->getEntry(); - unsigned Addr = - CompileUnitOffsets[Die->getAbstractCompileUnit()] + - Origin->getOffset(); - + unsigned Addr = Origin->getOffset(); Asm->EmitInt32(Addr); break; } @@ -3007,10 +3123,14 @@ Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version"); Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)"); - for (ValueMap >::iterator - I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) { - MDNode *Node = I->first; - SmallVector &Labels = I->second; + for (SmallVector::iterator I = InlinedSPNodes.begin(), + E = InlinedSPNodes.end(); I != E; ++I) { + +// for (ValueMap >::iterator + // I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) { + MDNode *Node = *I; + ValueMap >::iterator II = InlineInfo.find(Node); + SmallVector &Labels = II->second; DISubprogram SP(Node); const char *LName = SP.getLinkageName(); const char *Name = SP.getName(); @@ -3024,17 +3144,21 @@ // __asm__ attribute. if (LName[0] == 1) LName = &LName[1]; - Asm->EmitString(LName); +// Asm->EmitString(LName); + EmitSectionOffset("string", "section_str", + StringPool.idFor(LName), false, true); + } Asm->EOL("MIPS linkage name"); - - Asm->EmitString(Name); Asm->EOL("Function name"); - +// Asm->EmitString(Name); + EmitSectionOffset("string", "section_str", + StringPool.idFor(Name), false, true); + Asm->EOL("Function name"); Asm->EmitULEB128Bytes(Labels.size()); Asm->EOL("Inline count"); - for (SmallVector::iterator LI = Labels.begin(), + for (SmallVector::iterator LI = Labels.begin(), LE = Labels.end(); LI != LE; ++LI) { - DIE *SP = ModuleCU->getDieMapSlotFor(Node); + DIE *SP = LI->second; Asm->EmitInt32(SP->getOffset()); Asm->EOL("DIE offset"); if (TD->getPointerSize() == sizeof(int32_t)) @@ -3042,7 +3166,7 @@ else O << MAI->getData64bitsDirective(); - PrintLabelName("label", *LI); Asm->EOL("low_pc"); + PrintLabelName("label", LI->first); Asm->EOL("low_pc"); } } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Nov 10 17:06:00 2009 @@ -134,52 +134,52 @@ /// bool shouldEmit; - // FunctionDbgScope - Top level scope for the current function. + // CurrentFnDbgScope - Top level scope for the current function. // - DbgScope *FunctionDbgScope; + DbgScope *CurrentFnDbgScope; /// DbgScopeMap - Tracks the scopes in the current function. + /// ValueMap DbgScopeMap; + /// ConcreteScopes - Tracks the concrete scopees in the current function. + /// These scopes are also included in DbgScopeMap. + ValueMap ConcreteScopes; + + /// AbstractScopes - Tracks the abstract scopes a module. These scopes are + /// not included DbgScopeMap. + ValueMap AbstractScopes; + SmallVectorAbstractScopesList; + + /// AbstractVariables - Collection on abstract variables. + ValueMap AbstractVariables; + + /// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked + /// (at the end of the module) as DW_AT_inline. + SmallPtrSet InlinedSubprogramDIEs; + + /// AbstractSubprogramDIEs - Collection of abstruct subprogram DIEs. + SmallPtrSet AbstractSubprogramDIEs; + /// ScopedGVs - Tracks global variables that are not at file scope. /// For example void f() { static int b = 42; } SmallVector ScopedGVs; - typedef DenseMap > + typedef SmallVector ScopeVector; + typedef DenseMap InsnToDbgScopeMapTy; - /// DbgScopeBeginMap - Maps instruction with a list DbgScopes it starts. + /// DbgScopeBeginMap - Maps instruction with a list of DbgScopes it starts. InsnToDbgScopeMapTy DbgScopeBeginMap; /// DbgScopeEndMap - Maps instruction with a list DbgScopes it ends. InsnToDbgScopeMapTy DbgScopeEndMap; - /// DbgAbstractScopeMap - Tracks abstract instance scopes in the current - /// function. - ValueMap DbgAbstractScopeMap; - - /// DbgConcreteScopeMap - Tracks concrete instance scopes in the current - /// function. - ValueMap > DbgConcreteScopeMap; - /// InlineInfo - Keep track of inlined functions and their location. This /// information is used to populate debug_inlined section. - ValueMap > InlineInfo; - - /// AbstractInstanceRootMap - Map of abstract instance roots of inlined - /// functions. These are subroutine entries that contain a DW_AT_inline - /// attribute. - DenseMap AbstractInstanceRootMap; - - /// AbstractInstanceRootList - List of abstract instance roots of inlined - /// functions. These are subroutine entries that contain a DW_AT_inline - /// attribute. - SmallVector AbstractInstanceRootList; - - /// LexicalScopeStack - A stack of lexical scopes. The top one is the current - /// scope. - SmallVector LexicalScopeStack; + typedef std::pair InlineInfoLabels; + ValueMap > InlineInfo; + SmallVector InlinedSPNodes; /// CompileUnitOffsets - A vector of the offsets of the compile units. This is /// used when calculating the "origin" of a concrete instance of an inlined @@ -361,10 +361,24 @@ /// DIE *CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit); - /// getDbgScope - Returns the scope associated with the given descriptor. - /// + /// getUpdatedDbgScope - Find or create DbgScope assicated with + /// the instruction. Initialize scope and update scope hierarchy. + DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt); + + /// createDbgScope - Create DbgScope for the scope. + void createDbgScope(MDNode *Scope, MDNode *InlinedAt); DbgScope *getOrCreateScope(MDNode *N); - DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt); + DbgScope *getOrCreateAbstractScope(MDNode *N); + + /// findAbstractVariable - Find abstract variable associated with Var. + DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx, + DILocation &Loc); + + DIE *UpdateSubprogramScopeDIE(MDNode *SPNode); + DIE *ConstructLexicalScopeDIE(DbgScope *Scope); + DIE *ConstructScopeDIE(DbgScope *Scope); + DIE *ConstructInlinedScopeDIE(DbgScope *Scope); + DIE *ConstructVariableDIE(DbgVariable *DV, DbgScope *S, CompileUnit *Unit); /// ConstructDbgScope - Construct the components of a scope. /// @@ -372,10 +386,10 @@ unsigned ParentStartID, unsigned ParentEndID, DIE *ParentDie, CompileUnit *Unit); - /// ConstructFunctionDbgScope - Construct the scope for the subprogram. + /// ConstructCurrentFnDbgScope - Construct the scope for the subprogram. /// - void ConstructFunctionDbgScope(DbgScope *RootScope, - bool AbstractScope = false); + void ConstructCurrentFnDbgScope(DbgScope *RootScope, + bool AbstractScope = false); /// ConstructDefaultDbgScope - Construct a default scope for the subprogram. /// @@ -544,13 +558,6 @@ /// RecordVariable - Indicate the declaration of a local variable. void RecordVariable(MDNode *N, unsigned FrameIndex); - //// RecordInlinedFnStart - Indicate the start of inlined subroutine. - unsigned RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU, - unsigned Line, unsigned Col); - - /// RecordInlinedFnEnd - Indicate the end of inlined subroutine. - unsigned RecordInlinedFnEnd(DISubprogram &SP); - /// ExtractScopeInformation - Scan machine instructions in this function /// and collect DbgScopes. Return true, if atleast one scope was found. bool ExtractScopeInformation(MachineFunction *MF); @@ -558,15 +565,16 @@ /// CollectVariableInfo - Populate DbgScope entries with variables' info. void CollectVariableInfo(); - /// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that - /// start with this machine instruction. - void SetDbgScopeBeginLabels(const MachineInstr *MI, unsigned Label); - /// SetDbgScopeEndLabels - Update DbgScope end labels for the scopes that /// end with this machine instruction. void SetDbgScopeEndLabels(const MachineInstr *MI, unsigned Label); -}; + /// BeginScope - Process beginning of a scope starting at Label. + void BeginScope(const MachineInstr *MI, unsigned Label); + + /// EndScope - Prcess end of a scope. + void EndScope(const MachineInstr *MI); +}; } // End of namespace llvm #endif Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Tue Nov 10 17:06:00 2009 @@ -108,20 +108,9 @@ return DD && DD->ShouldEmitDwarfDebug(); } -//// RecordInlinedFnStart -unsigned DwarfWriter::RecordInlinedFnStart(DISubprogram SP, DICompileUnit CU, - unsigned Line, unsigned Col) { - return DD->RecordInlinedFnStart(SP, CU, Line, Col); +void DwarfWriter::BeginScope(const MachineInstr *MI, unsigned L) { + DD->BeginScope(MI, L); } - -/// RecordInlinedFnEnd - Indicate the end of inlined subroutine. -unsigned DwarfWriter::RecordInlinedFnEnd(DISubprogram SP) { - return DD->RecordInlinedFnEnd(SP); -} - -void DwarfWriter::SetDbgScopeBeginLabels(const MachineInstr *MI, unsigned L) { - DD->SetDbgScopeEndLabels(MI, L); -} -void DwarfWriter::SetDbgScopeEndLabels(const MachineInstr *MI, unsigned L) { - DD->SetDbgScopeBeginLabels(MI, L); +void DwarfWriter::EndScope(const MachineInstr *MI) { + DD->EndScope(MI); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Nov 10 17:06:00 2009 @@ -43,6 +43,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" @@ -347,21 +348,9 @@ && DW->ShouldEmitDwarfDebug()) { unsigned ID = 0; DISubprogram Subprogram(REI->getContext()); - if (isInlinedFnEnd(*REI, MF.getFunction())) { - // This is end of an inlined function. - const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); - ID = DW->RecordInlinedFnEnd(Subprogram); - if (ID) - // Returned ID is 0 if this is unbalanced "end of inlined - // scope". This could happen if optimizer eats dbg intrinsics - // or "beginning of inlined scope" is not recoginized due to - // missing location info. In such cases, ignore this region.end. - BuildMI(MBB, DL, II).addImm(ID); - } else { - const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); - ID = DW->RecordRegionEnd(REI->getContext()); - BuildMI(MBB, DL, II).addImm(ID); - } + const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); + ID = DW->RecordRegionEnd(REI->getContext()); + BuildMI(MBB, DL, II).addImm(ID); } return true; } @@ -371,28 +360,6 @@ || !DW->ShouldEmitDwarfDebug()) return true; - if (isInlinedFnStart(*FSI, MF.getFunction())) { - // This is a beginning of an inlined function. - - // If llvm.dbg.func.start is seen in a new block before any - // llvm.dbg.stoppoint intrinsic then the location info is unknown. - // FIXME : Why DebugLoc is reset at the beginning of each block ? - DebugLoc PrevLoc = DL; - if (PrevLoc.isUnknown()) - return true; - // Record the source line. - setCurDebugLoc(ExtractDebugLocation(*FSI, MF.getDebugLocInfo())); - - DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc); - DISubprogram SP(FSI->getSubprogram()); - unsigned LabelID = - DW->RecordInlinedFnStart(SP,DICompileUnit(PrevLocTpl.Scope), - PrevLocTpl.Line, PrevLocTpl.Col); - const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); - BuildMI(MBB, DL, II).addImm(LabelID); - return true; - } - // This is a beginning of a new function. MF.setDefaultDebugLoc(ExtractDebugLocation(*FSI, MF.getDebugLocInfo())); @@ -416,8 +383,13 @@ StaticAllocaMap.find(AI); if (SI == StaticAllocaMap.end()) break; // VLAs. int FI = SI->second; - if (MMI) - MMI->setVariableDbgInfo(DI->getVariable(), FI); + if (MMI) { + MetadataContext &TheMetadata = + DI->getParent()->getContext().getMetadata(); + unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); + MDNode *Dbg = TheMetadata.getMD(MDDbgKind, DI); + MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); + } #ifndef ATTACH_DEBUG_INFO_TO_AN_INSN DW->RecordVariable(DI->getVariable(), FI); #endif Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Nov 10 17:06:00 2009 @@ -26,6 +26,7 @@ #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/GCStrategy.h" @@ -3931,25 +3932,8 @@ || !DW->ShouldEmitDwarfDebug()) return 0; - MachineFunction &MF = DAG.getMachineFunction(); DISubprogram Subprogram(REI.getContext()); - if (isInlinedFnEnd(REI, MF.getFunction())) { - // This is end of inlined function. Debugging information for inlined - // function is not handled yet (only supported by FastISel). - if (OptLevel == CodeGenOpt::None) { - unsigned ID = DW->RecordInlinedFnEnd(Subprogram); - if (ID != 0) - // Returned ID is 0 if this is unbalanced "end of inlined - // scope". This could happen if optimizer eats dbg intrinsics or - // "beginning of inlined scope" is not recoginized due to missing - // location info. In such cases, do ignore this region.end. - DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), - getRoot(), ID)); - } - return 0; - } - unsigned LabelID = DW->RecordRegionEnd(REI.getContext()); DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), @@ -3963,37 +3947,6 @@ return 0; MachineFunction &MF = DAG.getMachineFunction(); - // This is a beginning of an inlined function. - if (isInlinedFnStart(FSI, MF.getFunction())) { - if (OptLevel != CodeGenOpt::None) - // FIXME: Debugging informaation for inlined function is only - // supported at CodeGenOpt::Node. - return 0; - - DebugLoc PrevLoc = CurDebugLoc; - // If llvm.dbg.func.start is seen in a new block before any - // llvm.dbg.stoppoint intrinsic then the location info is unknown. - // FIXME : Why DebugLoc is reset at the beginning of each block ? - if (PrevLoc.isUnknown()) - return 0; - - // Record the source line. - setCurDebugLoc(ExtractDebugLocation(FSI, MF.getDebugLocInfo())); - - if (!DW || !DW->ShouldEmitDwarfDebug()) - return 0; - DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc); - DISubprogram SP(FSI.getSubprogram()); - DICompileUnit CU(PrevLocTpl.Scope); - unsigned LabelID = DW->RecordInlinedFnStart(SP, CU, - PrevLocTpl.Line, - PrevLocTpl.Col); - DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), - getRoot(), LabelID)); - return 0; - } - - // This is a beginning of a new function. MF.setDefaultDebugLoc(ExtractDebugLocation(FSI, MF.getDebugLocInfo())); if (!DW || !DW->ShouldEmitDwarfDebug()) @@ -4028,8 +3981,13 @@ int FI = SI->second; #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - if (MMI) - MMI->setVariableDbgInfo(Variable, FI); + if (MMI) { + MetadataContext &TheMetadata = + DI.getParent()->getContext().getMetadata(); + unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); + MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &DI); + MMI->setVariableDbgInfo(Variable, FI, Dbg); + } #else DW->RecordVariable(Variable, FI); #endif Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Nov 10 17:06:00 2009 @@ -387,13 +387,14 @@ if (MDDbgKind) { // Update DebugLoc if debug information is attached with this // instruction. - if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); - SDL->setCurDebugLoc(Loc); - if (MF->getDefaultDebugLoc().isUnknown()) - MF->setDefaultDebugLoc(Loc); - } + if (!isa(I)) + if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { + DILocation DILoc(Dbg); + DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); + SDL->setCurDebugLoc(Loc); + if (MF->getDefaultDebugLoc().isUnknown()) + MF->setDefaultDebugLoc(Loc); + } } if (!isa(I)) SDL->visit(*I); @@ -750,14 +751,15 @@ if (MDDbgKind) { // Update DebugLoc if debug information is attached with this // instruction. - if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, BI)) { - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, - MF.getDebugLocInfo()); - FastIS->setCurDebugLoc(Loc); - if (MF.getDefaultDebugLoc().isUnknown()) - MF.setDefaultDebugLoc(Loc); - } + if (!isa(BI)) + if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, BI)) { + DILocation DILoc(Dbg); + DebugLoc Loc = ExtractDebugLocation(DILoc, + MF.getDebugLocInfo()); + FastIS->setCurDebugLoc(Loc); + if (MF.getDefaultDebugLoc().isUnknown()) + MF.setDefaultDebugLoc(Loc); + } } // Just before the terminator instruction, insert instructions to Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Tue Nov 10 17:06:00 2009 @@ -20,6 +20,7 @@ #include "llvm/IntrinsicInst.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include "llvm/Analysis/ConstantFolding.h" @@ -346,6 +347,27 @@ Ops.size(), TD); } +static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD, + LLVMContext &Context) { + DILocation ILoc(InsnMD); + if (ILoc.isNull()) return InsnMD; + + DILocation CallLoc(TheCallMD); + if (CallLoc.isNull()) return InsnMD; + + DILocation OrigLocation = ILoc.getOrigLocation(); + MDNode *NewLoc = TheCallMD; + if (!OrigLocation.isNull()) + NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD, Context); + + SmallVector MDVs; + MDVs.push_back(InsnMD->getElement(0)); // Line + MDVs.push_back(InsnMD->getElement(1)); // Col + MDVs.push_back(InsnMD->getElement(2)); // Scope + MDVs.push_back(NewLoc); + return MDNode::get(Context, MDVs.data(), MDVs.size()); +} + /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, /// except that it does some simple constant prop and DCE on the fly. The /// effect of this is to copy significantly less code in cases where (for @@ -358,7 +380,8 @@ SmallVectorImpl &Returns, const char *NameSuffix, ClonedCodeInfo *CodeInfo, - const TargetData *TD) { + const TargetData *TD, + Instruction *TheCall) { assert(NameSuffix && "NameSuffix cannot be null!"); #ifndef NDEBUG @@ -397,19 +420,49 @@ // references as we go. This uses ValueMap to do all the hard work. // BasicBlock::iterator I = NewBB->begin(); + + LLVMContext &Context = OldFunc->getContext(); + unsigned DbgKind = Context.getMetadata().getMDKind("dbg"); + MDNode *TheCallMD = NULL; + SmallVector MDVs; + if (TheCall && TheCall->hasMetadata()) + TheCallMD = Context.getMetadata().getMD(DbgKind, TheCall); // Handle PHI nodes specially, as we have to remove references to dead // blocks. if (PHINode *PN = dyn_cast(I)) { // Skip over all PHI nodes, remembering them for later. BasicBlock::const_iterator OldI = BI->begin(); - for (; (PN = dyn_cast(I)); ++I, ++OldI) + for (; (PN = dyn_cast(I)); ++I, ++OldI) { + if (I->hasMetadata()) + if (TheCallMD) { + if (MDNode *IMD = Context.getMetadata().getMD(DbgKind, I)) { + MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD, Context); + Context.getMetadata().addMD(DbgKind, NewMD, I); + } + } else + // The cloned instruction has dbg info but the call instruction + // does not have dbg info. Remove dbg info from cloned instruction. + Context.getMetadata().removeMD(DbgKind, I); PHIToResolve.push_back(cast(OldI)); + } } // Otherwise, remap the rest of the instructions normally. - for (; I != NewBB->end(); ++I) + for (; I != NewBB->end(); ++I) { + if (I->hasMetadata()) + if (TheCallMD) { + if (MDNode *IMD = Context.getMetadata().getMD(DbgKind, I)) { + MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD, Context); + Context.getMetadata().addMD(DbgKind, NewMD, I); + } + } else + // The cloned instruction has dbg info but the call instruction + // does not have dbg info. Remove dbg info from cloned instruction. + Context.getMetadata().removeMD(DbgKind, I); + RemapInstruction(I, ValueMap); + } } // Defer PHI resolution until rest of function is resolved, PHI resolution Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=86748&r1=86747&r2=86748&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Nov 10 17:06:00 2009 @@ -386,7 +386,7 @@ // (which can happen, e.g., because an argument was constant), but we'll be // happy with whatever the cloner can do. CloneAndPruneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i", - &InlinedFunctionInfo, TD); + &InlinedFunctionInfo, TD, TheCall); // Remember the first block that is newly cloned over. FirstNewBlock = LastBlock; ++FirstNewBlock; From dpatel at apple.com Tue Nov 10 17:07:00 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Nov 2009 23:07:00 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86749 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-debug.cpp llvm-debug.h Message-ID: <200911102307.nAAN71xq006494@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 17:07:00 2009 New Revision: 86749 URL: http://llvm.org/viewvc/llvm-project?rev=86749&view=rev Log: Attach locatin info with llvm.dbg.declare. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp llvm-gcc-4.2/trunk/gcc/llvm-debug.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=86749&r1=86748&r2=86749&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Nov 10 17:07:00 2009 @@ -304,7 +304,7 @@ TheDebugInfo->EmitDeclare(ResultDecl, dwarf::DW_TAG_return_variable, "agg.result", RetTy, Tmp, - Builder.GetInsertBlock()); + Builder); } ++AI; } @@ -602,7 +602,7 @@ if (!isInvRef && TheDebugInfo) TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable, Name, TREE_TYPE(Args), - AI, Builder.GetInsertBlock()); + AI, Builder); ++AI; } else { // Otherwise, we create an alloca to hold the argument value and provide @@ -614,7 +614,7 @@ if (TheDebugInfo) { TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable, Name, TREE_TYPE(Args), Tmp, - Builder.GetInsertBlock()); + Builder); } // Emit annotate intrinsic if arg has annotate attr @@ -646,6 +646,9 @@ // Not supported yet. } + if (TheDebugInfo) + TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder); + // As it turns out, not all temporaries are associated with blocks. For those // that aren't, emit them now. for (tree t = cfun->unexpanded_var_list; t; t = TREE_CHAIN(t)) { @@ -1656,11 +1659,11 @@ if (DECL_NAME(decl)) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_auto_variable, Name, TREE_TYPE(decl), AI, - Builder.GetInsertBlock()); + Builder); } else if (TREE_CODE(decl) == RESULT_DECL) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_return_variable, Name, TREE_TYPE(decl), AI, - Builder.GetInsertBlock()); + Builder); } } } Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=86749&r1=86748&r2=86749&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Nov 10 17:07:00 2009 @@ -309,7 +309,8 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." void DebugInfo::EmitDeclare(tree decl, unsigned Tag, const char *Name, - tree type, Value *AI, BasicBlock *CurBB) { + tree type, Value *AI, + LLVMBuilder &Builder) { // Do not emit variable declaration info, for now. if (optimize) @@ -330,7 +331,9 @@ Loc.line, getOrCreateType(type)); // Insert an llvm.dbg.declare into the current block. - DebugFactory.InsertDeclare(AI, D, CurBB); + Instruction *Call = DebugFactory.InsertDeclare(AI, D, + Builder.GetInsertBlock()); + Builder.SetDebugLocation(Call); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=86749&r1=86748&r2=86749&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue Nov 10 17:07:00 2009 @@ -92,8 +92,7 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." void EmitDeclare(tree_node *decl, unsigned Tag, const char *Name, - tree_node *type, Value *AI, - BasicBlock *CurBB); + tree_node *type, Value *AI, LLVMBuilder &Builder); /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of /// source line. From dalej at apple.com Tue Nov 10 17:16:41 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 10 Nov 2009 23:16:41 -0000 Subject: [llvm-commits] [llvm] r86751 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/PowerPC/vec_auto_constant.ll Message-ID: <200911102316.nAANGfeJ006865@zion.cs.uiuc.edu> Author: johannes Date: Tue Nov 10 17:16:41 2009 New Revision: 86751 URL: http://llvm.org/viewvc/llvm-project?rev=86751&view=rev Log: Emit correct code when making a ConstantPool entry for a vector constant whose component type is not a legal type for the target. (If the target ConstantPool cannot handle this type either, it has an opportunity to merge elements. In practice any target with 8-bit bytes must support i8 *as data*). 7320806 (partial). Added: llvm/trunk/test/CodeGen/PowerPC/vec_auto_constant.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=86751&r1=86750&r2=86751&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Nov 10 17:16:41 2009 @@ -1813,10 +1813,19 @@ CV.push_back(const_cast(V->getConstantFPValue())); } else if (ConstantSDNode *V = dyn_cast(Node->getOperand(i))) { - CV.push_back(const_cast(V->getConstantIntValue())); + if (OpVT==EltVT) + CV.push_back(const_cast(V->getConstantIntValue())); + else { + // If OpVT and EltVT don't match, EltVT is not legal and the + // element values have been promoted/truncated earlier. Undo this; + // we don't want a v16i8 to become a v16i32 for example. + const ConstantInt *CI = V->getConstantIntValue(); + CV.push_back(ConstantInt::get(EltVT.getTypeForEVT(*DAG.getContext()), + CI->getZExtValue())); + } } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); - const Type *OpNTy = OpVT.getTypeForEVT(*DAG.getContext()); + const Type *OpNTy = EltVT.getTypeForEVT(*DAG.getContext()); CV.push_back(UndefValue::get(OpNTy)); } } Added: llvm/trunk/test/CodeGen/PowerPC/vec_auto_constant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/vec_auto_constant.ll?rev=86751&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/vec_auto_constant.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/vec_auto_constant.ll Tue Nov 10 17:16:41 2009 @@ -0,0 +1,36 @@ +; RUN: llc < %s -march=ppc32 -mtriple=powerpc-apple-darwin -mcpu=g5 | FileCheck %s +; Formerly produced .long, 7320806 (partial) +; CHECK: .byte 22 +; CHECK: .byte 21 +; CHECK: .byte 20 +; CHECK: .byte 3 +; CHECK: .byte 25 +; CHECK: .byte 24 +; CHECK: .byte 23 +; CHECK: .byte 3 +; CHECK: .byte 28 +; CHECK: .byte 27 +; CHECK: .byte 26 +; CHECK: .byte 3 +; CHECK: .byte 31 +; CHECK: .byte 30 +; CHECK: .byte 29 +; CHECK: .byte 3 + at baz = common global <16 x i8> zeroinitializer ; <<16 x i8>*> [#uses=1] + +define void @foo(<16 x i8> %x) nounwind ssp { +entry: + %x_addr = alloca <16 x i8> ; <<16 x i8>*> [#uses=2] + %temp = alloca <16 x i8> ; <<16 x i8>*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store <16 x i8> %x, <16 x i8>* %x_addr + store <16 x i8> , <16 x i8>* %temp, align 16 + %0 = load <16 x i8>* %x_addr, align 16 ; <<16 x i8>> [#uses=1] + %1 = load <16 x i8>* %temp, align 16 ; <<16 x i8>> [#uses=1] + %tmp = add <16 x i8> %0, %1 ; <<16 x i8>> [#uses=1] + store <16 x i8> %tmp, <16 x i8>* @baz, align 16 + br label %return + +return: ; preds = %entry + ret void +} From isanbard at gmail.com Tue Nov 10 17:18:33 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Nov 2009 23:18:33 -0000 Subject: [llvm-commits] [llvm] r86752 - /llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Message-ID: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> Author: void Date: Tue Nov 10 17:18:33 2009 New Revision: 86752 URL: http://llvm.org/viewvc/llvm-project?rev=86752&view=rev Log: Test this on Darwin only. Modified: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Modified: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll?rev=86752&r1=86751&r2=86752&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Tue Nov 10 17:18:33 2009 @@ -1,4 +1,6 @@ ; RUN: llc < %s -march=ppc32 -disable-fp-elim | FileCheck %s +; XFAIL: * +; XTARGET: darwin define i32 @_Z4funci(i32 %a) ssp { ; CHECK: mflr r0 From dpatel at apple.com Tue Nov 10 17:20:05 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Nov 2009 23:20:05 -0000 Subject: [llvm-commits] [llvm] r86753 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911102320.nAANK5sX007003@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 17:20:04 2009 New Revision: 86753 URL: http://llvm.org/viewvc/llvm-project?rev=86753&view=rev Log: Ignore variable if scope info is not available. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86753&r1=86752&r2=86753&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 10 17:20:04 2009 @@ -1453,7 +1453,8 @@ DIGlobalVariable GV(N); if (GV.getContext().getNode() == SPNode) { DIE *ScopedGVDie = CreateGlobalVariableDIE(ModuleCU, GV); - SPDie->AddChild(ScopedGVDie); + if (ScopedGVDie) + SPDie->AddChild(ScopedGVDie); } } return SPDie; @@ -2076,7 +2077,9 @@ ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode()); if (!Scope) Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode()); - assert (Scope && "Unable to find variable scope!"); + // If variable scope is not found then skip this variable. + if (!Scope) + continue; DbgVariable *RegVar = new DbgVariable(DV, VP.first); Scope->AddVariable(RegVar); From anton at korobeynikov.info Tue Nov 10 17:30:47 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 11 Nov 2009 02:30:47 +0300 Subject: [llvm-commits] [llvm] r86752 - /llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll In-Reply-To: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> References: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> Message-ID: > URL: http://llvm.org/viewvc/llvm-project?rev=86752&view=rev > Log: > Test this on Darwin only. Why? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From clattner at apple.com Tue Nov 10 17:36:44 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 10 Nov 2009 15:36:44 -0800 Subject: [llvm-commits] [llvm] r86752 - /llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll In-Reply-To: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> References: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> Message-ID: <1DDDB4CD-4B98-4888-B950-0AC1EB147C3A@apple.com> This should specify a triple for the test (mtriple) not xfail. -chris On Nov 10, 2009, at 3:18 PM, Bill Wendling wrote: > Author: void > Date: Tue Nov 10 17:18:33 2009 > New Revision: 86752 > > URL: http://llvm.org/viewvc/llvm-project?rev=86752&view=rev > Log: > Test this on Darwin only. > > Modified: > llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll > > Modified: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll?rev=86752&r1=86751&r2=86752&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll (original) > +++ llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Tue Nov 10 > 17:18:33 2009 > @@ -1,4 +1,6 @@ > ; RUN: llc < %s -march=ppc32 -disable-fp-elim | FileCheck %s > +; XFAIL: * > +; XTARGET: darwin > > define i32 @_Z4funci(i32 %a) ssp { > ; CHECK: mflr r0 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Nov 10 17:40:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 23:40:49 -0000 Subject: [llvm-commits] [llvm] r86754 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911102340.nAANen9E007765@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 17:40:49 2009 New Revision: 86754 URL: http://llvm.org/viewvc/llvm-project?rev=86754&view=rev Log: I did this a week or two ago Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86754&r1=86753&r2=86754&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Tue Nov 10 17:40:49 2009 @@ -1612,12 +1612,6 @@ //===---------------------------------------------------------------------===// -IPSCCP is propagating elements of first class aggregates, but is not propagating -the entire aggregate itself. This leads it to miss opportunities, for example -in test/Transforms/SCCP/ipsccp-basic.ll:test5b. - -//===---------------------------------------------------------------------===// - int func(int a, int b) { if (a & 0x80) b |= 0x80; else b &= ~0x80; return b; } Generates this: From sabre at nondot.org Tue Nov 10 17:47:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 23:47:45 -0000 Subject: [llvm-commits] [llvm] r86756 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911102347.nAANljSu008010@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 17:47:45 2009 New Revision: 86756 URL: http://llvm.org/viewvc/llvm-project?rev=86756&view=rev Log: add a note Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86756&r1=86755&r2=86756&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Tue Nov 10 17:47:45 2009 @@ -339,6 +339,8 @@ extra register for the function when effective_addr2 is declared as U64 than when it is declared U32. +PHI Slicing could be extended to do this. + //===---------------------------------------------------------------------===// LSR should know what GPR types a target has. This code: From sabre at nondot.org Tue Nov 10 17:54:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 23:54:10 -0000 Subject: [llvm-commits] [llvm] r86758 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <200911102354.nAANsARq008321@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 17:54:10 2009 New Revision: 86758 URL: http://llvm.org/viewvc/llvm-project?rev=86758&view=rev Log: jump threading does everything that condprop does any more. This passes bootstrap on darwin i386. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=86758&r1=86757&r2=86758&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Nov 10 17:54:10 2009 @@ -125,8 +125,6 @@ PM->add(createCFGSimplificationPass()); // Merge & remove BBs PM->add(createInstructionCombiningPass()); // Combine silly seq's - // FIXME: CondProp breaks critical edges, which is slow. - PM->add(createCondPropagationPass()); // Propagate conditionals PM->add(createTailCallEliminationPass()); // Eliminate tail calls PM->add(createCFGSimplificationPass()); // Merge & remove BBs PM->add(createReassociatePass()); // Reassociate expressions @@ -146,7 +144,7 @@ // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. PM->add(createInstructionCombiningPass()); - PM->add(createCondPropagationPass()); // Propagate conditionals + PM->add(createJumpThreadingPass()); // Thread jumps PM->add(createDeadStoreEliminationPass()); // Delete dead stores PM->add(createAggressiveDCEPass()); // Delete dead instructions PM->add(createCFGSimplificationPass()); // Merge & remove BBs From sabre at nondot.org Tue Nov 10 17:54:41 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 23:54:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86759 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200911102354.nAANsgHI008350@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 17:54:41 2009 New Revision: 86759 URL: http://llvm.org/viewvc/llvm-project?rev=86759&view=rev Log: no need to link in condprop Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=86759&r1=86758&r2=86759&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Tue Nov 10 17:54:41 2009 @@ -75,7 +75,6 @@ llvm::createAggressiveDCEPass(); llvm::createConstantMergePass(); llvm::createIndVarSimplifyPass(); - llvm::createCondPropagationPass(); llvm::createGlobalOptimizerPass(); llvm::createJumpThreadingPass(); llvm::createFunctionInliningPass(); From evan.cheng at apple.com Tue Nov 10 18:00:21 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 00:00:21 -0000 Subject: [llvm-commits] [llvm] r86761 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll Message-ID: <200911110000.nAB00LTk008585@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 10 18:00:21 2009 New Revision: 86761 URL: http://llvm.org/viewvc/llvm-project?rev=86761&view=rev Log: Block terminator may be a switch. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=86761&r1=86760&r2=86761&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Nov 10 18:00:21 2009 @@ -2428,7 +2428,7 @@ if (!L->isLoopExiting(CondBB)) return false; BranchInst *TermBr = dyn_cast(CondBB->getTerminator()); - if (!TermBr->isConditional()) + if (!TermBr || !TermBr->isConditional()) return false; Value *User = *Cond->use_begin(); Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll?rev=86761&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll Tue Nov 10 18:00:21 2009 @@ -0,0 +1,130 @@ +; RUN: llc < %s -mtriple=i386-apple-darwin11 + +define void @_ZN4llvm20SelectionDAGLowering14visitInlineAsmENS_8CallSiteE() nounwind ssp align 2 { +entry: + br i1 undef, label %bb3.i, label %bb4.i + +bb3.i: ; preds = %entry + unreachable + +bb4.i: ; preds = %entry + br i1 undef, label %bb.i.i, label %_ZNK4llvm8CallSite14getCalledValueEv.exit + +bb.i.i: ; preds = %bb4.i + unreachable + +_ZNK4llvm8CallSite14getCalledValueEv.exit: ; preds = %bb4.i + br i1 undef, label %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit, label %bb6.i + +bb6.i: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit + unreachable + +_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit + br i1 undef, label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit, label %bb.i + +bb.i: ; preds = %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit + br label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + +_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit: ; preds = %bb.i, %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit + br i1 undef, label %bb50, label %bb27 + +bb27: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + br i1 undef, label %bb1.i727, label %bb.i.i726 + +bb.i.i726: ; preds = %bb27 + unreachable + +bb1.i727: ; preds = %bb27 + unreachable + +bb50: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + br label %bb107 + +bb51: ; preds = %bb107 + br i1 undef, label %bb105, label %bb106 + +bb105: ; preds = %bb51 + unreachable + +bb106: ; preds = %bb51 + br label %bb107 + +bb107: ; preds = %bb106, %bb50 + br i1 undef, label %bb108, label %bb51 + +bb108: ; preds = %bb107 + br i1 undef, label %bb242, label %bb114 + +bb114: ; preds = %bb108 + br i1 undef, label %bb141, label %bb116 + +bb116: ; preds = %bb114 + br i1 undef, label %bb120, label %bb121 + +bb120: ; preds = %bb116 + unreachable + +bb121: ; preds = %bb116 + unreachable + +bb141: ; preds = %bb114 + br i1 undef, label %bb182, label %bb143 + +bb143: ; preds = %bb141 + br label %bb157 + +bb144: ; preds = %bb.i.i.i843 + switch i32 undef, label %bb155 [ + i32 2, label %bb153 + i32 6, label %bb153 + i32 4, label %bb153 + ] + +bb153: ; preds = %bb144, %bb144, %bb144 + %indvar.next = add i32 %indvar, 1 ; [#uses=1] + br label %bb157 + +bb155: ; preds = %bb144 + unreachable + +bb157: ; preds = %bb153, %bb143 + %indvar = phi i32 [ %indvar.next, %bb153 ], [ 0, %bb143 ] ; [#uses=2] + %0 = icmp eq i32 undef, %indvar ; [#uses=1] + switch i16 undef, label %bb6.i841 [ + i16 9, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + i16 26, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + ] + +bb6.i841: ; preds = %bb157 + unreachable + +_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit: ; preds = %bb157, %bb157 + br i1 undef, label %bb.i.i.i843, label %bb1.i.i.i844 + +bb.i.i.i843: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + br i1 %0, label %bb158, label %bb144 + +bb1.i.i.i844: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + unreachable + +bb158: ; preds = %bb.i.i.i843 + br i1 undef, label %bb177, label %bb176 + +bb176: ; preds = %bb158 + unreachable + +bb177: ; preds = %bb158 + br i1 undef, label %bb179, label %bb178 + +bb178: ; preds = %bb177 + unreachable + +bb179: ; preds = %bb177 + unreachable + +bb182: ; preds = %bb141 + unreachable + +bb242: ; preds = %bb108 + unreachable +} From dpatel at apple.com Tue Nov 10 18:18:40 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 00:18:40 -0000 Subject: [llvm-commits] [llvm] r86763 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-11-10-ParentScope.ll Message-ID: <200911110018.nAB0Iel8009212@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 18:18:40 2009 New Revision: 86763 URL: http://llvm.org/viewvc/llvm-project?rev=86763&view=rev Log: While creating DbgScopes, do not forget parent scope. Added: llvm/trunk/test/DebugInfo/2009-11-10-ParentScope.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86763&r1=86762&r2=86763&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 10 18:18:40 2009 @@ -2124,6 +2124,8 @@ return; WScope = new DbgScope(NULL, DIDescriptor(Scope), NULL); DbgScopeMap.insert(std::make_pair(Scope, WScope)); + if (DIDescriptor(Scope).isLexicalBlock()) + createDbgScope(DILexicalBlock(Scope).getContext().getNode(), NULL); return; } Added: llvm/trunk/test/DebugInfo/2009-11-10-ParentScope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-10-ParentScope.ll?rev=86763&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-10-ParentScope.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-10-ParentScope.ll Tue Nov 10 18:18:40 2009 @@ -0,0 +1,26 @@ +; RUN: llc < %s -o /dev/null +%struct.htab = type { i32 (i8*)*, i32 (i8*, i8*)*, void (i8*)*, i8**, i64, i64, i64, i32, i32, i8* (i64, i64)*, void (i8*)*, i8*, i8* (i8*, i64, i64)*, void (i8*, i8*)*, i32, [4 x i8] } + +define i8* @htab_find_with_hash(%struct.htab* %htab, i8* %element, i32 %hash) nounwind { +entry: + br i1 undef, label %land.lhs.true, label %if.end, !dbg !0 + +land.lhs.true: ; preds = %entry + unreachable + +if.end: ; preds = %entry + store i8* undef, i8** undef, !dbg !7 + ret i8* undef, !dbg !10 +} + +!0 = metadata !{i32 571, i32 3, metadata !1, null} +!1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ] +!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"htab_find_with_hash", metadata !"htab_find_with_hash", metadata !"htab_find_with_hash", metadata !3, i32 561, metadata !4, i1 false, i1 true}; [DW_TAG_subprogram ] +!3 = metadata !{i32 458769, i32 0, i32 12, metadata !"hashtab.c", metadata !"/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!4 = metadata !{i32 458773, metadata !3, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !5, i32 0}; [DW_TAG_subroutine_type ] +!5 = metadata !{metadata !6} +!6 = metadata !{i32 458767, metadata !3, metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, null}; [DW_TAG_pointer_type ] +!7 = metadata !{i32 583, i32 7, metadata !8, null} +!8 = metadata !{i32 458763, metadata !9}; [DW_TAG_lexical_block ] +!9 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ] +!10 = metadata !{i32 588, i32 1, metadata !2, null} From sabre at nondot.org Tue Nov 10 18:21:22 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 00:21:22 -0000 Subject: [llvm-commits] [llvm] r86765 - in /llvm/trunk: include/llvm/Analysis/LiveValues.h lib/Analysis/LiveValues.cpp Message-ID: <200911110021.nAB0LM2f009348@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 18:21:21 2009 New Revision: 86765 URL: http://llvm.org/viewvc/llvm-project?rev=86765&view=rev Log: remove redundant foward declaration. This function is already in Analysis/Passes.h Modified: llvm/trunk/include/llvm/Analysis/LiveValues.h llvm/trunk/lib/Analysis/LiveValues.cpp Modified: llvm/trunk/include/llvm/Analysis/LiveValues.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LiveValues.h?rev=86765&r1=86764&r2=86765&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LiveValues.h (original) +++ llvm/trunk/include/llvm/Analysis/LiveValues.h Tue Nov 10 18:21:21 2009 @@ -94,10 +94,6 @@ bool isKilledInBlock(const Value *V, const BasicBlock *BB); }; -/// createLiveValuesPass - This creates an instance of the LiveValues pass. -/// -FunctionPass *createLiveValuesPass(); - -} +} // end namespace llvm #endif Modified: llvm/trunk/lib/Analysis/LiveValues.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LiveValues.cpp?rev=86765&r1=86764&r2=86765&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LiveValues.cpp (original) +++ llvm/trunk/lib/Analysis/LiveValues.cpp Tue Nov 10 18:21:21 2009 @@ -17,7 +17,9 @@ #include "llvm/Analysis/LoopInfo.h" using namespace llvm; -FunctionPass *llvm::createLiveValuesPass() { return new LiveValues(); } +namespace llvm { + FunctionPass *createLiveValuesPass() { return new LiveValues(); } +} char LiveValues::ID = 0; static RegisterPass From sabre at nondot.org Tue Nov 10 18:21:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 00:21:59 -0000 Subject: [llvm-commits] [llvm] r86766 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911110021.nAB0Lxfh009400@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 18:21:58 2009 New Revision: 86766 URL: http://llvm.org/viewvc/llvm-project?rev=86766&view=rev Log: add a fixme Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86766&r1=86765&r2=86766&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 18:21:58 2009 @@ -169,6 +169,10 @@ /// Ignore PHI nodes, these will be flattened when duplication happens. BasicBlock::const_iterator I = BB->getFirstNonPHI(); + // FIXME: THREADING will delete values that are just used to compute the + // branch, so they shouldn't count against the duplication cost. + + // Sum up the cost of each instruction until we get to the terminator. Don't // include the terminator because the copy won't include it. unsigned Size = 0; From sabre at nondot.org Tue Nov 10 18:22:30 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 00:22:30 -0000 Subject: [llvm-commits] [llvm] r86767 - in /llvm/trunk: include/llvm/Analysis/LazyValueInfo.h include/llvm/Analysis/Passes.h include/llvm/LinkAllPasses.h lib/Analysis/CMakeLists.txt lib/Analysis/LazyValueInfo.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911110022.nAB0MVa4009438@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 18:22:30 2009 New Revision: 86767 URL: http://llvm.org/viewvc/llvm-project?rev=86767&view=rev Log: Stub out a new lazy value info pass, which will eventually vend value constraint information to the optimizer. Added: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/Passes.h llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/lib/Analysis/CMakeLists.txt llvm/trunk/test/Transforms/JumpThreading/basic.ll Added: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=86767&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (added) +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Tue Nov 10 18:22:30 2009 @@ -0,0 +1,43 @@ +//===- LazyValueInfo.h - Value constraint analysis --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the interface for lazy computation of value constraint +// information. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_LIVEVALUES_H +#define LLVM_ANALYSIS_LIVEVALUES_H + +#include "llvm/Pass.h" + +namespace llvm { + +/// LazyValueInfo - This pass computes, caches, and vends lazy value constraint +/// information. +class LazyValueInfo : public FunctionPass { +public: + static char ID; + LazyValueInfo(); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + virtual void releaseMemory(); + + virtual bool runOnFunction(Function &F) { + // Fully lazy. + return false; + } +}; + +} // end namespace llvm + +#endif + Modified: llvm/trunk/include/llvm/Analysis/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Passes.h?rev=86767&r1=86766&r2=86767&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Passes.h (original) +++ llvm/trunk/include/llvm/Analysis/Passes.h Tue Nov 10 18:22:30 2009 @@ -139,6 +139,12 @@ // createLiveValuesPass - This creates an instance of the LiveValues pass. // FunctionPass *createLiveValuesPass(); + + //===--------------------------------------------------------------------===// + // + /// createLazyValueInfoPass - This creates an instance of the LazyValueInfo + /// pass. + FunctionPass *createLazyValueInfoPass(); //===--------------------------------------------------------------------===// // Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=86767&r1=86766&r2=86767&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Tue Nov 10 18:22:30 2009 @@ -82,6 +82,7 @@ (void) llvm::createInternalizePass(false); (void) llvm::createLCSSAPass(); (void) llvm::createLICMPass(); + (void) llvm::createLazyValueInfoPass(); (void) llvm::createLiveValuesPass(); (void) llvm::createLoopDependenceAnalysisPass(); (void) llvm::createLoopExtractorPass(); Modified: llvm/trunk/lib/Analysis/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=86767&r1=86766&r2=86767&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) +++ llvm/trunk/lib/Analysis/CMakeLists.txt Tue Nov 10 18:22:30 2009 @@ -18,6 +18,7 @@ InstructionSimplify.cpp Interval.cpp IntervalPartition.cpp + LazyValueInfo.cpp LibCallAliasAnalysis.cpp LibCallSemantics.cpp LiveValues.cpp Added: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86767&view=auto ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (added) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Nov 10 18:22:30 2009 @@ -0,0 +1,31 @@ +//===- LazyValueInfo.cpp - Value constraint analysis ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the interface for lazy computation of value constraint +// information. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/LazyValueInfo.h" +using namespace llvm; + +char LazyValueInfo::ID = 0; +static RegisterPass +X("lazy-value-info", "Lazy Value Information Analysis", false, true); + +namespace llvm { + FunctionPass *createLazyValueInfoPass() { return new LazyValueInfo(); } +} + +LazyValueInfo::LazyValueInfo() : FunctionPass(&ID) { +} + +void LazyValueInfo::releaseMemory() { + +} Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86767&r1=86766&r2=86767&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Tue Nov 10 18:22:30 2009 @@ -284,3 +284,29 @@ } + + +;;; Duplicate condition to avoid xor of cond. +define i32 @test10(i1 %cond, i1 %cond2) { +Entry: +; CHECK: @test10 + %v1 = call i32 @f1() + br i1 %cond, label %Merge, label %F1 + +F1: + br label %Merge + +Merge: + %B = phi i1 [true, %Entry], [%cond2, %F1] + %M = icmp eq i32 %v1, 192 + %N = xor i1 %B, %M + br i1 %N, label %T2, label %F2 + +T2: + ret i32 123 + +F2: + ret i32 %v1 +} + + From espindola at google.com Tue Nov 10 18:25:45 2009 From: espindola at google.com (Rafael Espindola) Date: Tue, 10 Nov 2009 19:25:45 -0500 Subject: [llvm-commits] [PATCH] LTO code generator options In-Reply-To: <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> Message-ID: <38a0d8450911101625s5e3b7cb0m31ec0ce4d4144dc@mail.gmail.com> 2009/11/10 Viktor Kutuzov : > Is this Ok to submit? Small comments: * StringRef is normally passed by value. * Can you put the header reordering and white space in an independent patch? * Part of the alignment looks strange: + if (!MAttrs.empty()) + features.AddFeatures(MAttrs); * getArchNameForLLVMArchType is not used > Best regards, > Viktor Cheers, -- Rafael ?vila de Esp?ndola From sabre at nondot.org Tue Nov 10 18:27:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 00:27:55 -0000 Subject: [llvm-commits] [llvm] r86768 - /llvm/trunk/test/Transforms/JumpThreading/basic.ll Message-ID: <200911110027.nAB0RtlB009606@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 18:27:54 2009 New Revision: 86768 URL: http://llvm.org/viewvc/llvm-project?rev=86768&view=rev Log: oops, didn't mean to commit this, no harm, but add a todoops, didn't mean to commit this, no harm, but add a todoo Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86768&r1=86767&r2=86768&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Tue Nov 10 18:27:54 2009 @@ -287,6 +287,7 @@ ;;; Duplicate condition to avoid xor of cond. +;;; TODO: Make this happen. define i32 @test10(i1 %cond, i1 %cond2) { Entry: ; CHECK: @test10 From daniel at zuster.org Tue Nov 10 18:28:38 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 00:28:38 -0000 Subject: [llvm-commits] [llvm] r86769 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <200911110028.nAB0ScGp009640@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 18:28:38 2009 New Revision: 86769 URL: http://llvm.org/viewvc/llvm-project?rev=86769&view=rev Log: llvm-gcc/clang don't (won't?) need this hack. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=86769&r1=86768&r2=86769&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Nov 10 18:28:38 2009 @@ -16,7 +16,8 @@ // // FIXME: This is a huge hack, to work around ridiculously awful compile times // on this file with gcc-4.2 on Darwin, in Release mode. -#if defined(__APPLE__) && defined(__OPTIMIZE__) && !defined(NDEBUG) +#if (!defined(__llvm__) && defined(__APPLE__) && \ + defined(__OPTIMIZE__) && !defined(NDEBUG)) #define NDEBUG #endif From daniel at zuster.org Tue Nov 10 18:28:53 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 00:28:53 -0000 Subject: [llvm-commits] [llvm] r86770 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringRef.cpp unittests/ADT/StringRefTest.cpp Message-ID: <200911110028.nAB0SrIG009661@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 18:28:53 2009 New Revision: 86770 URL: http://llvm.org/viewvc/llvm-project?rev=86770&view=rev Log: Add From arguments to StringRef search functions, and tweak doxyments. Also, add unittests for find_first_of and find_first_not_of. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/Support/StringRef.cpp llvm/trunk/unittests/ADT/StringRefTest.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=86770&r1=86769&r2=86770&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Nov 10 18:28:53 2009 @@ -152,8 +152,8 @@ /// /// \return - The index of the first occurence of \arg C, or npos if not /// found. - size_t find(char C) const { - for (size_t i = 0, e = Length; i != e; ++i) + size_t find(char C, size_t From = 0) const { + for (size_t i = std::min(From, Length), e = Length; i != e; ++i) if (Data[i] == C) return i; return npos; @@ -163,7 +163,7 @@ /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. - size_t find(StringRef Str) const; + size_t find(StringRef Str, size_t From = 0) const; /// rfind - Search for the last character \arg C in the string. /// @@ -186,17 +186,25 @@ /// found. size_t rfind(StringRef Str) const; - /// find_first_of - Find the first instance of the specified character or - /// return npos if not in string. Same as find. - size_type find_first_of(char C) const { return find(C); } - - /// find_first_of - Find the first character from the string 'Chars' in the - /// current string or return npos if not in string. - size_type find_first_of(StringRef Chars) const; + /// find_first_of - Find the first character in the string that is \arg C, + /// or npos if not found. Same as find. + size_type find_first_of(char C, size_t From = 0) const { return find(C); } + + /// find_first_of - Find the first character in the string that is in \arg + /// Chars, or npos if not found. + /// + /// Note: O(size() * Chars.size()) + size_type find_first_of(StringRef Chars, size_t From = 0) const; + + /// find_first_not_of - Find the first character in the string that is not + /// \arg C or npos if not found. + size_type find_first_not_of(char C, size_t From = 0) const; /// find_first_not_of - Find the first character in the string that is not - /// in the string 'Chars' or return npos if all are in string. Same as find. - size_type find_first_not_of(StringRef Chars) const; + /// in the string \arg Chars, or npos if not found. + /// + /// Note: O(size() * Chars.size()) + size_type find_first_not_of(StringRef Chars, size_t From = 0) const; /// @} /// @name Helpful Algorithms Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=86770&r1=86769&r2=86770&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Tue Nov 10 18:28:53 2009 @@ -24,11 +24,11 @@ /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. -size_t StringRef::find(StringRef Str) const { +size_t StringRef::find(StringRef Str, size_t From) const { size_t N = Str.size(); if (N > Length) return npos; - for (size_t i = 0, e = Length - N + 1; i != e; ++i) + for (size_t e = Length - N + 1, i = std::min(From, e); i != e; ++i) if (substr(i, N).equals(Str)) return i; return npos; @@ -50,19 +50,34 @@ return npos; } -/// find_first_of - Find the first character from the string 'Chars' in the -/// current string or return npos if not in string. -StringRef::size_type StringRef::find_first_of(StringRef Chars) const { - for (size_type i = 0, e = Length; i != e; ++i) +/// find_first_of - Find the first character in the string that is in \arg +/// Chars, or npos if not found. +/// +/// Note: O(size() * Chars.size()) +StringRef::size_type StringRef::find_first_of(StringRef Chars, + size_t From) const { + for (size_type i = std::min(From, Length), e = Length; i != e; ++i) if (Chars.find(Data[i]) != npos) return i; return npos; } /// find_first_not_of - Find the first character in the string that is not -/// in the string 'Chars' or return npos if all are in string. Same as find. -StringRef::size_type StringRef::find_first_not_of(StringRef Chars) const { - for (size_type i = 0, e = Length; i != e; ++i) +/// \arg C or npos if not found. +StringRef::size_type StringRef::find_first_not_of(char C, size_t From) const { + for (size_type i = std::min(From, Length), e = Length; i != e; ++i) + if (Data[i] != C) + return i; + return npos; +} + +/// find_first_not_of - Find the first character in the string that is not +/// in the string \arg Chars, or npos if not found. +/// +/// Note: O(size() * Chars.size()) +StringRef::size_type StringRef::find_first_not_of(StringRef Chars, + size_t From) const { + for (size_type i = std::min(From, Length), e = Length; i != e; ++i) if (Chars.find(Data[i]) == npos) return i; return npos; Modified: llvm/trunk/unittests/ADT/StringRefTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringRefTest.cpp?rev=86770&r1=86769&r2=86770&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/StringRefTest.cpp (original) +++ llvm/trunk/unittests/ADT/StringRefTest.cpp Tue Nov 10 18:28:53 2009 @@ -125,6 +125,8 @@ EXPECT_EQ(0U, Str.find("hello")); EXPECT_EQ(1U, Str.find("ello")); EXPECT_EQ(StringRef::npos, Str.find("zz")); + EXPECT_EQ(2U, Str.find("ll", 2)); + EXPECT_EQ(StringRef::npos, Str.find("ll", 3)); EXPECT_EQ(3U, Str.rfind('l')); EXPECT_EQ(StringRef::npos, Str.rfind('z')); @@ -132,6 +134,14 @@ EXPECT_EQ(0U, Str.rfind("hello")); EXPECT_EQ(1U, Str.rfind("ello")); EXPECT_EQ(StringRef::npos, Str.rfind("zz")); + + EXPECT_EQ(2U, Str.find_first_of('l')); + EXPECT_EQ(1U, Str.find_first_of("el")); + EXPECT_EQ(StringRef::npos, Str.find_first_of("xyz")); + + EXPECT_EQ(1U, Str.find_first_not_of('h')); + EXPECT_EQ(4U, Str.find_first_not_of("hel")); + EXPECT_EQ(StringRef::npos, Str.find_first_not_of("hello")); } TEST(StringRefTest, Count) { From dpatel at apple.com Tue Nov 10 18:31:36 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 00:31:36 -0000 Subject: [llvm-commits] [llvm] r86771 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-11-10-CurrentFn.ll Message-ID: <200911110031.nAB0VaMj009767@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 18:31:36 2009 New Revision: 86771 URL: http://llvm.org/viewvc/llvm-project?rev=86771&view=rev Log: Do not assume first function scope seen represents current function. Added: llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86771&r1=86770&r2=86771&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 10 18:31:36 2009 @@ -1347,8 +1347,9 @@ NScope->setFirstInsn(MI); if (!Parent && !InlinedAt) { - assert (!CurrentFnDbgScope && "Unexpected function scope!"); - CurrentFnDbgScope = NScope; + StringRef SPName = DISubprogram(N).getLinkageName(); + if (SPName == MF->getFunction()->getName()) + CurrentFnDbgScope = NScope; } if (GetConcreteScope) { Added: llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll?rev=86771&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll Tue Nov 10 18:31:36 2009 @@ -0,0 +1,19 @@ + +declare void @foo() + +define void @bar(i32 %i) nounwind ssp { +entry: + tail call void @foo() nounwind, !dbg !0 + ret void, !dbg !6 +} + +!0 = metadata !{i32 9, i32 0, metadata !1, null} +!1 = metadata !{i32 458798, i32 0, metadata !2, metadata !"baz", metadata !"baz", metadata !"baz", metadata !2, i32 8, metadata !3, i1 true, i1 true}; [DW_TAG_subprogram ] +!2 = metadata !{i32 458769, i32 0, i32 1, metadata !"2007-12-VarArrayDebug.c", metadata !"/Volumes/Data/ddunbar/llvm/test/FrontendC", metadata !"4.2.1 (Based on Apple Inc. build 5653) (LLVM build)", i1 true, i1 true, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!3 = metadata !{i32 458773, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0}; [DW_TAG_subroutine_type ] +!4 = metadata !{null, metadata !5} +!5 = metadata !{i32 458788, metadata !2, metadata !"int", metadata !2, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] +!6 = metadata !{i32 18, i32 0, metadata !7, null} +!7 = metadata !{i32 458798, i32 0, metadata !2, metadata !"bar", metadata !"bar", metadata !"bar", metadata !2, i32 16, metadata !8, i1 false, i1 true}; [DW_TAG_subprogram ] +!8 = metadata !{i32 458773, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !9, i32 0}; [DW_TAG_subroutine_type ] +!9 = metadata !{null} From daniel at zuster.org Tue Nov 10 18:43:14 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 00:43:14 -0000 Subject: [llvm-commits] [llvm] r86773 - /llvm/trunk/include/llvm/ADT/Triple.h Message-ID: <200911110043.nAB0hEe2010196@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 18:43:14 2009 New Revision: 86773 URL: http://llvm.org/viewvc/llvm-project?rev=86773&view=rev Log: Add Triple::str() which returns the contents of the Triple as a string, as a more readable alternative to getTriple(). Modified: llvm/trunk/include/llvm/ADT/Triple.h Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=86773&r1=86772&r2=86773&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Tue Nov 10 18:43:14 2009 @@ -160,6 +160,8 @@ /// @name Direct Component Access /// @{ + const std::string &str() const { return Data; } + const std::string &getTriple() const { return Data; } /// getArchName - Get the architecture (first) component of the From isanbard at gmail.com Tue Nov 10 19:24:59 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Nov 2009 01:24:59 -0000 Subject: [llvm-commits] [llvm] r86779 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfException.cpp test/CodeGen/X86/hidden-vis-5.ll Message-ID: <200911110124.nAB1OxY8012160@zion.cs.uiuc.edu> Author: void Date: Tue Nov 10 19:24:59 2009 New Revision: 86779 URL: http://llvm.org/viewvc/llvm-project?rev=86779&view=rev Log: Make sure that the exception handling data has the same visibility as the function it's generated for. Added: llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=86779&r1=86778&r2=86779&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Tue Nov 10 19:24:59 2009 @@ -232,11 +232,16 @@ // corresponding function is static, this should not be externally visible. if (!TheFunc->hasLocalLinkage()) if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) - O << GlobalEHDirective << EHFrameInfo.FnName << "\n"; + O << GlobalEHDirective << EHFrameInfo.FnName << '\n'; // If corresponding function is weak definition, this should be too. if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) - O << MAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n"; + O << MAI->getWeakDefDirective() << EHFrameInfo.FnName << '\n'; + + // If corresponding function is hidden, this should be too. + if (TheFunc->hasHiddenVisibility()) + if (const char *HiddenDirective = MAI->getHiddenDirective()) + O << HiddenDirective << EHFrameInfo.FnName << '\n' ; // If there are no calls then you can't unwind. This may mean we can omit the // EH Frame, but some environments do not handle weak absolute symbols. If Added: llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll?rev=86779&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll (added) +++ llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll Tue Nov 10 19:24:59 2009 @@ -0,0 +1,30 @@ +; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s +; + + at .str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] + +define hidden void @func() nounwind ssp { +entry: + %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +declare i32 @puts(i8*) + +define hidden i32 @main() nounwind ssp { +entry: + %retval = alloca i32 ; [#uses=1] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @func() nounwind + br label %return + +return: ; preds = %entry + %retval1 = load i32* %retval ; [#uses=1] + ret i32 %retval1 +} + +; CHECK: .private_extern _func.eh +; CHECK: .private_extern _main.eh From dpatel at apple.com Tue Nov 10 19:41:10 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 01:41:10 -0000 Subject: [llvm-commits] [llvm] r86784 - /llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Message-ID: <200911110141.nAB1fAwU012751@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 10 19:41:10 2009 New Revision: 86784 URL: http://llvm.org/viewvc/llvm-project?rev=86784&view=rev Log: XFAIL for now. Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=86784&r1=86783&r2=86784&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Tue Nov 10 19:41:10 2009 @@ -12,7 +12,7 @@ // Only works on ppc (but not apple-darwin9), x86 and x86_64. Should // generalize? -// XFAIL: alpha,arm,powerpc-apple-darwin9 +// XFAIL: * #include From isanbard at gmail.com Tue Nov 10 19:41:32 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Nov 2009 01:41:32 -0000 Subject: [llvm-commits] [llvm] r86785 - /llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll Message-ID: <200911110141.nAB1fWNh012772@zion.cs.uiuc.edu> Author: void Date: Tue Nov 10 19:41:32 2009 New Revision: 86785 URL: http://llvm.org/viewvc/llvm-project?rev=86785&view=rev Log: Fix test to work on every platform. Modified: llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll Modified: llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll?rev=86785&r1=86784&r2=86785&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll (original) +++ llvm/trunk/test/CodeGen/X86/hidden-vis-5.ll Tue Nov 10 19:41:32 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s +; RUN: llc < %s -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s ; @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1] From isanbard at gmail.com Tue Nov 10 19:44:22 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Nov 2009 01:44:22 -0000 Subject: [llvm-commits] [llvm] r86786 - /llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Message-ID: <200911110144.nAB1iN2H012862@zion.cs.uiuc.edu> Author: void Date: Tue Nov 10 19:44:22 2009 New Revision: 86786 URL: http://llvm.org/viewvc/llvm-project?rev=86786&view=rev Log: Fix test to work on every platform. Modified: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Modified: llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll?rev=86786&r1=86785&r2=86786&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll Tue Nov 10 19:44:22 2009 @@ -1,6 +1,4 @@ -; RUN: llc < %s -march=ppc32 -disable-fp-elim | FileCheck %s -; XFAIL: * -; XTARGET: darwin +; RUN: llc < %s -mtriple=powerpc-apple-darwin8 -disable-fp-elim | FileCheck %s define i32 @_Z4funci(i32 %a) ssp { ; CHECK: mflr r0 From isanbard at gmail.com Tue Nov 10 19:44:41 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Nov 2009 17:44:41 -0800 Subject: [llvm-commits] [llvm] r86752 - /llvm/trunk/test/CodeGen/PowerPC/ppc-prologue.ll In-Reply-To: References: <200911102318.nAANIX7t006938@zion.cs.uiuc.edu> Message-ID: <3ECCAF66-AB93-44F5-BEA5-600AA9BE780D@gmail.com> Erm...because I forgot about the -mtriple. :-) Fixed. (I hope) -bw On Nov 10, 2009, at 3:30 PM, Anton Korobeynikov wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=86752&view=rev >> Log: >> Test this on Darwin only. > Why? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Nov 10 20:08:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 02:08:33 -0000 Subject: [llvm-commits] [llvm] r86789 - in /llvm/trunk: include/llvm/Analysis/LazyValueInfo.h lib/Analysis/LazyValueInfo.cpp lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911110208.nAB28X0E013556@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 20:08:33 2009 New Revision: 86789 URL: http://llvm.org/viewvc/llvm-project?rev=86789&view=rev Log: stub out some LazyValueInfo interfaces, and have JumpThreading start using them in a trivial way when -enable-jump-threading-lvi is passed. enable-jump-threading-lvi will be my playground for awhile. Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h llvm/trunk/lib/Analysis/LazyValueInfo.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=86789&r1=86788&r2=86789&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Tue Nov 10 20:08:33 2009 @@ -18,23 +18,44 @@ #include "llvm/Pass.h" namespace llvm { - + class Constant; + class TargetData; + class Value; + /// LazyValueInfo - This pass computes, caches, and vends lazy value constraint /// information. class LazyValueInfo : public FunctionPass { + class TargetData *TD; + void *PImpl; public: static char ID; - LazyValueInfo(); + LazyValueInfo() : FunctionPass(&ID), PImpl(0) {} + /// Tristate - This is used to return yes/no/dunno results. + enum Tristate { + Unknown = -1, No = 0, Yes = 1 + }; + + + // Public query interface. + + + /// isEqual - Determine whether the specified value is known to be equal or + /// not-equal to the specified constant at the end of the specified block. + Tristate isEqual(Value *V, Constant *C, BasicBlock *BB); + + /// getConstant - Determine whether the specified value is known to be a + /// constant at the end of the specified block. Return null if not. + Constant *getConstant(Value *V, BasicBlock *BB); + + + // Implementation boilerplate. + virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } virtual void releaseMemory(); - - virtual bool runOnFunction(Function &F) { - // Fully lazy. - return false; - } + virtual bool runOnFunction(Function &F); }; } // end namespace llvm Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86789&r1=86788&r2=86789&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Nov 10 20:08:33 2009 @@ -13,6 +13,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LazyValueInfo.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" +#include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Target/TargetData.h" +#include "llvm/ADT/PointerIntPair.h" using namespace llvm; char LazyValueInfo::ID = 0; @@ -23,9 +28,119 @@ FunctionPass *createLazyValueInfoPass() { return new LazyValueInfo(); } } -LazyValueInfo::LazyValueInfo() : FunctionPass(&ID) { + +//===----------------------------------------------------------------------===// +// LVILatticeVal +//===----------------------------------------------------------------------===// + +/// LVILatticeVal - This is the information tracked by LazyValueInfo for each +/// value. +/// +/// FIXME: This is basically just for bringup, this can be made a lot more rich +/// in the future. +/// +namespace { +class LVILatticeVal { + enum LatticeValueTy { + /// undefined - This LLVM Value has no known value yet. + undefined, + /// constant - This LLVM Value has a specific constant value. + constant, + /// overdefined - This instruction is not known to be constant, and we know + /// it has a value. + overdefined + }; + + /// Val: This stores the current lattice value along with the Constant* for + /// the constant if this is a 'constant' value. + PointerIntPair Val; + +public: + LVILatticeVal() : Val(0, undefined) {} + + bool isUndefined() const { return Val.getInt() == undefined; } + bool isConstant() const { return Val.getInt() == constant; } + bool isOverdefined() const { return Val.getInt() == overdefined; } + + Constant *getConstant() const { + assert(isConstant() && "Cannot get the constant of a non-constant!"); + return Val.getPointer(); + } + + /// getConstantInt - If this is a constant with a ConstantInt value, return it + /// otherwise return null. + ConstantInt *getConstantInt() const { + if (isConstant()) + return dyn_cast(getConstant()); + return 0; + } + + /// markOverdefined - Return true if this is a change in status. + bool markOverdefined() { + if (isOverdefined()) + return false; + Val.setInt(overdefined); + return true; + } + + /// markConstant - Return true if this is a change in status. + bool markConstant(Constant *V) { + if (isConstant()) { + assert(getConstant() == V && "Marking constant with different value"); + return false; + } + + assert(isUndefined()); + Val.setInt(constant); + assert(V && "Marking constant with NULL"); + Val.setPointer(V); + } + +}; + +} // end anonymous namespace. + + +//===----------------------------------------------------------------------===// +// LazyValueInfo Impl +//===----------------------------------------------------------------------===// + +bool LazyValueInfo::runOnFunction(Function &F) { + TD = getAnalysisIfAvailable(); + // Fully lazy. + return false; } void LazyValueInfo::releaseMemory() { + // No caching yet. +} + + +/// isEqual - Determine whether the specified value is known to be equal or +/// not-equal to the specified constant at the end of the specified block. +LazyValueInfo::Tristate +LazyValueInfo::isEqual(Value *V, Constant *C, BasicBlock *BB) { + // If already a constant, we can use constant folding. + if (Constant *VC = dyn_cast(V)) { + // Ignore FP for now. TODO, consider what form of equality we want. + if (C->getType()->isFPOrFPVector()) + return Unknown; + + Constant *Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, VC,C,TD); + if (ConstantInt *ResCI = dyn_cast(Res)) + return ResCI->isZero() ? No : Yes; + } + // Not a very good implementation. + return Unknown; } + +Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) { + // If already a constant, return it. + if (Constant *VC = dyn_cast(V)) + return VC; + + // Not a very good implementation. + return 0; +} + Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86789&r1=86788&r2=86789&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 20:08:33 2009 @@ -17,6 +17,7 @@ #include "llvm/LLVMContext.h" #include "llvm/Pass.h" #include "llvm/Analysis/InstructionSimplify.h" +#include "llvm/Analysis/LazyValueInfo.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/SSAUpdater.h" @@ -40,6 +41,12 @@ cl::desc("Max block size to duplicate for jump threading"), cl::init(6), cl::Hidden); +// Turn on use of LazyValueInfo. +static cl::opt +EnableLVI("enable-jump-threading-lvi", cl::ReallyHidden); + + + namespace { /// This pass performs 'jump threading', which looks at blocks that have /// multiple predecessors and multiple successors. If one or more of the @@ -59,6 +66,7 @@ /// class JumpThreading : public FunctionPass { TargetData *TD; + LazyValueInfo *LVI; #ifdef NDEBUG SmallPtrSet LoopHeaders; #else @@ -69,8 +77,13 @@ JumpThreading() : FunctionPass(&ID) {} bool runOnFunction(Function &F); - void FindLoopHeaders(Function &F); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + if (EnableLVI) + AU.addRequired(); + } + + void FindLoopHeaders(Function &F); bool ProcessBlock(BasicBlock *BB); bool ThreadEdge(BasicBlock *BB, const SmallVectorImpl &PredBBs, BasicBlock *SuccBB); @@ -106,6 +119,7 @@ bool JumpThreading::runOnFunction(Function &F) { DEBUG(errs() << "Jump threading on function '" << F.getName() << "'\n"); TD = getAnalysisIfAvailable(); + LVI = EnableLVI ? &getAnalysis() : 0; FindLoopHeaders(F); @@ -235,31 +249,48 @@ /// predecessors. If so, return the known list of value and pred BB in the /// result vector. If a value is known to be undef, it is returned as null. /// -/// The BB basic block is known to start with a PHI node. -/// /// This returns true if there were any known values. /// -/// -/// TODO: Per PR2563, we could infer value range information about a predecessor -/// based on its terminator. bool JumpThreading:: ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ - PHINode *TheFirstPHI = cast(BB->begin()); - // If V is a constantint, then it is known in all predecessors. if (isa(V) || isa(V)) { ConstantInt *CI = dyn_cast(V); - Result.resize(TheFirstPHI->getNumIncomingValues()); - for (unsigned i = 0, e = Result.size(); i != e; ++i) - Result[i] = std::make_pair(CI, TheFirstPHI->getIncomingBlock(i)); + + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) + Result.push_back(std::make_pair(CI, *PI)); return true; } // If V is a non-instruction value, or an instruction in a different block, // then it can't be derived from a PHI. Instruction *I = dyn_cast(V); - if (I == 0 || I->getParent() != BB) + if (I == 0 || I->getParent() != BB) { + + // Okay, if this is a live-in value, see if it has a known value at the end + // of any of our predecessors. + // + // FIXME: This should be an edge property, not a block end property. + /// TODO: Per PR2563, we could infer value range information about a + /// predecessor based on its terminator. + // + if (LVI) { + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + // If the value is known by LazyValueInfo to be a constant in a + // predecessor, use that information to try to thread this block. + Constant *PredCst = LVI->getConstant(V, *PI); + if (PredCst == 0 || + (!isa(PredCst) && !isa(PredCst))) + continue; + + Result.push_back(std::make_pair(dyn_cast(PredCst), *PI)); + } + + return !Result.empty(); + } + return false; + } /// If I is a PHI node, then we know the incoming values for any constants. if (PHINode *PN = dyn_cast(I)) { @@ -517,12 +548,8 @@ // a PHI node in the current block. If we can prove that any predecessors // compute a predictable value based on a PHI node, thread those predecessors. // - // We only bother doing this if the current block has a PHI node and if the - // conditional instruction lives in the current block. If either condition - // fails, this won't be a computable value anyway. - if (CondInst->getParent() == BB && isa(BB->front())) - if (ProcessThreadableEdges(CondInst, BB)) - return true; + if (ProcessThreadableEdges(CondInst, BB)) + return true; // TODO: If we have: "br (X > 0)" and we have a predecessor where we know From vargaz at gmail.com Tue Nov 10 20:36:12 2009 From: vargaz at gmail.com (Zoltan Varga) Date: Wed, 11 Nov 2009 03:36:12 +0100 Subject: [llvm-commits] [PATH] Implement generation of dwarf unwind info on ARM ELF In-Reply-To: <295e750a0911082339p3428e9m3529e903f0bccf4e@mail.gmail.com> References: <295e750a0911082339p3428e9m3529e903f0bccf4e@mail.gmail.com> Message-ID: <295e750a0911101836g1855f75dp149882d3c86589e7@mail.gmail.com> Hi, Since writing this, I realized that ARM doesn't use .eh_frame for unwinding. So ignore this patch for now. Zoltan On Mon, Nov 9, 2009 at 8:39 AM, Zoltan Varga wrote: > Hi, > > The attached patch implements the generation of DWARF unwind info on ARM. > It is currently only enabled on ELF platforms when > -unwind-tables is passed to llc. > > I tested with manually by examining the output of objdump -W. > > Please review and commit if it looks ok. > > Zoltan > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091111/bb722dc4/attachment.html From grosbach at apple.com Tue Nov 10 20:47:19 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Nov 2009 02:47:19 -0000 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> Author: grosbach Date: Tue Nov 10 20:47:19 2009 New Revision: 86791 URL: http://llvm.org/viewvc/llvm-project?rev=86791&view=rev Log: The TBB and TBH instructions for Thumb2 are really handy for jump tables, but can only branch forward. To best take advantage of them, we'd like to adjust the basic blocks around a bit when reasonable. This patch puts basics in place to do that, with a super-simple algorithm for backwards jump table targets that creates a new branch after the jump table which branches backwards. Real heuristics for reordering blocks or other modifications rather than inserting branches will follow. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86791&r1=86790&r2=86791&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Nov 10 20:47:19 2009 @@ -31,6 +31,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; @@ -42,6 +43,12 @@ STATISTIC(NumT2CPShrunk, "Number of Thumb2 constantpool instructions shrunk"); STATISTIC(NumT2BrShrunk, "Number of Thumb2 immediate branches shrunk"); STATISTIC(NumCBZ, "Number of CBZ / CBNZ formed"); +STATISTIC(NumJTMoved, "Number of jump table destination blocks moved"); + + +static cl::opt +AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(false), + cl::desc("Adjust basic block layout to better use TB[BH]")); namespace { /// ARMConstantIslands - Due to limited PC-relative displacements, ARM @@ -202,6 +209,8 @@ bool OptimizeThumb2Instructions(MachineFunction &MF); bool OptimizeThumb2Branches(MachineFunction &MF); bool OptimizeThumb2JumpTables(MachineFunction &MF); + MachineBasicBlock *AdjustJTTargetBlockForward(MachineBasicBlock *BB, + MachineBasicBlock *JTBB); unsigned GetOffsetOf(MachineInstr *MI) const; void dumpBBs(); @@ -1560,7 +1569,7 @@ // FIXME: After the tables are shrunk, can we get rid some of the // constantpool tables? - const MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); + MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); const std::vector &JT = MJTI->getJumpTables(); for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) { MachineInstr *MI = T2JumpTables[i]; @@ -1571,10 +1580,33 @@ unsigned JTI = JTOP.getIndex(); assert(JTI < JT.size()); - bool ByteOk = true; - bool HalfWordOk = true; + // We prefer if target blocks for the jump table come after the jump + // instruction so we can use TB[BH]. Loop through the target blocks + // and try to adjust them such that that's true. unsigned JTOffset = GetOffsetOf(MI) + 4; const std::vector &JTBBs = JT[JTI].MBBs; + if (AdjustJumpTableBlocks) { + for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { + MachineBasicBlock *MBB = JTBBs[j]; + unsigned DstOffset = BBOffsets[MBB->getNumber()]; + + if (DstOffset < JTOffset) { + // The destination precedes the switch. Try to move the block forward + // so we have a positive offset. + MachineBasicBlock *NewBB = + AdjustJTTargetBlockForward(MBB, MI->getParent()); + if (NewBB) { + MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); + JTOffset = GetOffsetOf(MI) + 4; + DstOffset = BBOffsets[MBB->getNumber()]; + } + } + } + } + + bool ByteOk = true; + bool HalfWordOk = true; + JTOffset = GetOffsetOf(MI) + 4; for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { MachineBasicBlock *MBB = JTBBs[j]; unsigned DstOffset = BBOffsets[MBB->getNumber()]; @@ -1660,3 +1692,64 @@ return MadeChange; } + +MachineBasicBlock *ARMConstantIslands:: +AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB) +{ + MachineFunction &MF = *BB->getParent(); + + // FIXME: For now, instead of moving the block, we'll create a new block + // immediate following the jump that's an unconditional branch to the + // actual target. This is obviously not what we want for a real solution, + // but it's useful for proof of concept, and it may be a useful fallback + // later for cases where we otherwise can't move a block. + + // Create a new MBB for the code after the jump BB. + MachineBasicBlock *NewBB = + MF.CreateMachineBasicBlock(JTBB->getBasicBlock()); + MachineFunction::iterator MBBI = JTBB; ++MBBI; + MF.insert(MBBI, NewBB); + + // Add an unconditional branch from NewBB to BB. + // There doesn't seem to be meaningful DebugInfo available; this doesn't + // correspond directly to anything in the source. + assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); + BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB); + + // Update the CFG. + NewBB->addSuccessor(BB); + JTBB->removeSuccessor(BB); + JTBB->addSuccessor(NewBB); + + // Update internal data structures to account for the newly inserted MBB. + // This is almost the same as UpdateForInsertedWaterBlock, except that + // the Water goes after OrigBB, not NewBB. + MF.RenumberBlocks(NewBB); + + // Insert a size into BBSizes to align it properly with the (newly + // renumbered) block numbers. + BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); + + // Likewise for BBOffsets. + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); + + // Figure out how large the first NewMBB is. + unsigned NewBBSize = 0; + for (MachineBasicBlock::iterator I = NewBB->begin(), E = NewBB->end(); + I != E; ++I) + NewBBSize += TII->GetInstSizeInBytes(I); + + unsigned NewBBI = NewBB->getNumber(); + unsigned JTBBI = JTBB->getNumber(); + // Set the size of NewBB in BBSizes. + BBSizes[NewBBI] = NewBBSize; + + // ...and adjust BBOffsets for NewBB accordingly. + BBOffsets[NewBBI] = BBOffsets[JTBBI] + BBSizes[JTBBI]; + + // All BBOffsets following these blocks must be modified. + AdjustBBOffsetsAfter(NewBB, 4); + + ++NumJTMoved; + return NewBB; +} From espindola at google.com Tue Nov 10 21:05:34 2009 From: espindola at google.com (Rafael Espindola) Date: Tue, 10 Nov 2009 22:05:34 -0500 Subject: [llvm-commits] [patch] Remove dead code Message-ID: <38a0d8450911101905g34b9b885k5b19afbbe0aff0c7@mail.gmail.com> Can simple patches as the attached one be reviewed after being committed? Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: dead.patch Type: text/x-diff Size: 632 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091110/d8b40aac/attachment.bin From daniel at zuster.org Tue Nov 10 21:09:50 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 03:09:50 -0000 Subject: [llvm-commits] [llvm] r86794 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911110309.nAB39oHf015509@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 21:09:50 2009 New Revision: 86794 URL: http://llvm.org/viewvc/llvm-project?rev=86794&view=rev Log: Fix -Asserts warning. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86794&r1=86793&r2=86794&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 10 21:09:50 2009 @@ -1565,6 +1565,7 @@ DIScope DS(Scope->getScopeNode()); DISubprogram InlinedSP = getDISubprogram(DS.getNode()); DIE *&OriginSPDIE = ModuleCU->getDieMapSlotFor(InlinedSP.getNode()); + (void) OriginSPDIE; assert (OriginSPDIE && "Unable to find Origin DIE for the SP!"); DIE *AbsDIE = DV->getAbstractVariable()->getDIE(); assert (AbsDIE && "Unable to find Origin DIE for the Variable!"); From daniel at zuster.org Tue Nov 10 21:10:03 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 03:10:03 -0000 Subject: [llvm-commits] [llvm] r86795 - /llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll Message-ID: <200911110310.nAB3A3Yt015532@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 21:10:03 2009 New Revision: 86795 URL: http://llvm.org/viewvc/llvm-project?rev=86795&view=rev Log: Add missing run line. Devang, please check. Modified: llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll Modified: llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll?rev=86795&r1=86794&r2=86795&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll (original) +++ llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll Tue Nov 10 21:10:03 2009 @@ -1,3 +1,4 @@ +; RUN: llc < %s -o /dev/null declare void @foo() From deeppatel1987 at gmail.com Tue Nov 10 21:23:47 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Wed, 11 Nov 2009 03:23:47 -0000 Subject: [llvm-commits] [llvm] r86797 - in /llvm/trunk: lib/Support/CommandLine.cpp utils/TableGen/SubtargetEmitter.cpp Message-ID: <200911110323.nAB3NlpL016081@zion.cs.uiuc.edu> Author: sandeep Date: Tue Nov 10 21:23:46 2009 New Revision: 86797 URL: http://llvm.org/viewvc/llvm-project?rev=86797&view=rev Log: Show command-line args and features passed into backend in debug output. Approved by Evan Cheng. Modified: llvm/trunk/lib/Support/CommandLine.cpp llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Modified: llvm/trunk/lib/Support/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=86797&r1=86796&r2=86797&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Tue Nov 10 21:23:46 2009 @@ -17,6 +17,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/ManagedStatic.h" @@ -765,6 +766,11 @@ free(*i); } + DEBUG(errs() << "\nArgs: "; + for (int i = 0; i < argc; ++i) + errs() << argv[i] << ' '; + ); + // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); } Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=86797&r1=86796&r2=86797&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Tue Nov 10 21:23:46 2009 @@ -519,6 +519,8 @@ OS << Target; OS << "Subtarget::ParseSubtargetFeatures(const std::string &FS,\n" << " const std::string &CPU) {\n" + << " DEBUG(errs() << \"\\nFeatures:\" << FS);\n" + << " DEBUG(errs() << \"\\nCPU:\" << CPU);\n" << " SubtargetFeatures Features(FS);\n" << " Features.setCPUIfNone(CPU);\n" << " uint32_t Bits = Features.getBits(SubTypeKV, SubTypeKVSize,\n" @@ -558,6 +560,8 @@ EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS); + OS << "#include \"llvm/Support/Debug.h\"\n"; + OS << "#include \"llvm/Support/raw_ostream.h\"\n"; OS << "#include \"llvm/Target/SubtargetFeature.h\"\n"; OS << "#include \"llvm/Target/TargetInstrItineraries.h\"\n\n"; From clattner at apple.com Tue Nov 10 21:56:02 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 10 Nov 2009 19:56:02 -0800 Subject: [llvm-commits] [patch] Remove dead code In-Reply-To: <38a0d8450911101905g34b9b885k5b19afbbe0aff0c7@mail.gmail.com> References: <38a0d8450911101905g34b9b885k5b19afbbe0aff0c7@mail.gmail.com> Message-ID: On Nov 10, 2009, at 7:05 PM, Rafael Espindola wrote: > Can simple patches as the attached one be reviewed after being > committed? Absolutely, go for it. -Chris > > Cheers, > -- > Rafael ?vila de Esp?ndola > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From rafael.espindola at gmail.com Tue Nov 10 22:10:34 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 11 Nov 2009 04:10:34 -0000 Subject: [llvm-commits] [llvm] r86802 - /llvm/trunk/lib/CompilerDriver/Tool.cpp Message-ID: <200911110410.nAB4AZq2017981@zion.cs.uiuc.edu> Author: rafael Date: Tue Nov 10 22:10:24 2009 New Revision: 86802 URL: http://llvm.org/viewvc/llvm-project?rev=86802&view=rev Log: Remove dead code. Modified: llvm/trunk/lib/CompilerDriver/Tool.cpp Modified: llvm/trunk/lib/CompilerDriver/Tool.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Tool.cpp?rev=86802&r1=86801&r2=86802&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Tool.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Tool.cpp Tue Nov 10 22:10:24 2009 @@ -20,11 +20,6 @@ using namespace llvm; using namespace llvmc; -// SplitString is used by derived Tool classes. -typedef void (*SplitStringFunPtr)(const std::string&, - std::vector&, const char*); -SplitStringFunPtr ForceLinkageSplitString = &llvm::SplitString; - namespace { sys::Path MakeTempFile(const sys::Path& TempDir, const std::string& BaseName, const std::string& Suffix) { From daniel at zuster.org Tue Nov 10 23:19:18 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Nov 2009 05:19:18 -0000 Subject: [llvm-commits] [llvm] r86803 - /llvm/trunk/include/llvm/ADT/StringRef.h Message-ID: <200911110519.nAB5JJq1020571@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 10 23:19:11 2009 New Revision: 86803 URL: http://llvm.org/viewvc/llvm-project?rev=86803&view=rev Log: Add StringRef::split(StringRef), to complement StringRef::split(char). Modified: llvm/trunk/include/llvm/ADT/StringRef.h Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=86803&r1=86802&r2=86803&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Nov 10 23:19:11 2009 @@ -289,6 +289,23 @@ return std::make_pair(slice(0, Idx), slice(Idx+1, npos)); } + /// split - Split into two substrings around the first occurence of a + /// separator string. + /// + /// If \arg Separator is in the string, then the result is a pair (LHS, RHS) + /// such that (*this == LHS + Separator + RHS) is true and RHS is + /// maximal. If \arg Separator is not in the string, then the result is a + /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). + /// + /// \param Separator - The string to split on. + /// \return - The split substrings. + std::pair split(StringRef Separator) const { + size_t Idx = find(Separator); + if (Idx == npos) + return std::make_pair(*this, StringRef()); + return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos)); + } + /// rsplit - Split into two substrings around the last occurence of a /// separator character. /// From sabre at nondot.org Tue Nov 10 23:25:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 05:25:21 -0000 Subject: [llvm-commits] [llvm] r86804 - /llvm/trunk/test/Transforms/CondProp/ Message-ID: <200911110525.nAB5PLQ5020859@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 23:25:16 2009 New Revision: 86804 URL: http://llvm.org/viewvc/llvm-project?rev=86804&view=rev Log: remove condprop testcases. Removed: llvm/trunk/test/Transforms/CondProp/ From sabre at nondot.org Tue Nov 10 23:26:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Nov 2009 23:26:05 -0600 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html Message-ID: <200911110526.nAB5Q5dK020885@zion.cs.uiuc.edu> Changes in directory llvm-www: OpenProjects.html updated: 1.54 -> 1.55 --- Log message: this is done, thanks to Daveed for pointing this out. --- Diffs of the changes: (+1 -2) OpenProjects.html | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm-www/OpenProjects.html diff -u llvm-www/OpenProjects.html:1.54 llvm-www/OpenProjects.html:1.55 --- llvm-www/OpenProjects.html:1.54 Wed Oct 28 23:29:39 2009 +++ llvm-www/OpenProjects.html Tue Nov 10 23:24:12 2009 @@ -240,7 +240,6 @@
  • Improvements for Debug Information Generation
  • EH support for non-call exceptions
  • -
  • Support for multiple return values
  • Add support for representing Type Based Alias Analysis (TBAA) in the LLVM IR.
  • Many ideas for feature requests are stored in LLVM bugzilla. Just LLVM Compiler Infrastructure
    - Last modified: $Date: 2009/10/29 04:29:39 $ + Last modified: $Date: 2009/11/11 05:24:12 $ From jyasskin at google.com Tue Nov 10 23:30:03 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Wed, 11 Nov 2009 05:30:03 -0000 Subject: [llvm-commits] [llvm] r86807 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200911110530.nAB5U3mk021189@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Nov 10 23:30:02 2009 New Revision: 86807 URL: http://llvm.org/viewvc/llvm-project?rev=86807&view=rev Log: Fix JITTest.ModuleDeletion in -Asserts mode (which turns off JITEmitDebugInfo by default). Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=86807&r1=86806&r2=86807&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Tue Nov 10 23:30:02 2009 @@ -434,10 +434,16 @@ RJMM->deallocateFunctionBodyCalls.size()); SmallPtrSet ExceptionTablesDeallocated; + unsigned NumTablesDeallocated = 0; for (unsigned i = 0, e = RJMM->deallocateExceptionTableCalls.size(); i != e; ++i) { ExceptionTablesDeallocated.insert( RJMM->deallocateExceptionTableCalls[i].ET); + if (RJMM->deallocateExceptionTableCalls[i].ET != NULL) { + // If JITEmitDebugInfo is off, we'll "deallocate" NULL, which doesn't + // appear in startExceptionTableCalls. + NumTablesDeallocated++; + } } for (unsigned i = 0, e = RJMM->startExceptionTableCalls.size(); i != e; ++i) { EXPECT_TRUE(ExceptionTablesDeallocated.count( @@ -446,7 +452,7 @@ << RJMM->startExceptionTableCalls[i].F_dump; } EXPECT_EQ(RJMM->startExceptionTableCalls.size(), - RJMM->deallocateExceptionTableCalls.size()); + NumTablesDeallocated); } // This code is copied from JITEventListenerTest, but it only runs once for all From sabre at nondot.org Tue Nov 10 23:56:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 05:56:36 -0000 Subject: [llvm-commits] [llvm] r86810 - in /llvm/trunk: include/llvm-c/Transforms/Scalar.h include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/CMakeLists.txt lib/Transforms/Scalar/CondPropagate.cpp lib/Transforms/Scalar/Scalar.cpp Message-ID: <200911110556.nAB5uacl021976@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 10 23:56:35 2009 New Revision: 86810 URL: http://llvm.org/viewvc/llvm-project?rev=86810&view=rev Log: remove the now dead condprop pass, PR3906. Removed: llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp Modified: llvm/trunk/include/llvm-c/Transforms/Scalar.h llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Modified: llvm/trunk/include/llvm-c/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Transforms/Scalar.h?rev=86810&r1=86809&r2=86810&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm-c/Transforms/Scalar.h Tue Nov 10 23:56:35 2009 @@ -31,9 +31,6 @@ /** See llvm::createCFGSimplificationPass function. */ void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM); -/** See llvm::createCondPropagationPass function. */ -void LLVMAddCondPropagationPass(LLVMPassManagerRef PM); - /** See llvm::createDeadStoreEliminationPass function. */ void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM); Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=86810&r1=86809&r2=86810&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Tue Nov 10 23:56:35 2009 @@ -120,7 +120,6 @@ (void) llvm::createTailDuplicationPass(); (void) llvm::createJumpThreadingPass(); (void) llvm::createUnifyFunctionExitNodesPass(); - (void) llvm::createCondPropagationPass(); (void) llvm::createNullProfilerRSPass(); (void) llvm::createRSProfilingPass(); (void) llvm::createInstCountPass(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=86810&r1=86809&r2=86810&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Tue Nov 10 23:56:35 2009 @@ -171,14 +171,6 @@ //===----------------------------------------------------------------------===// // -// CondPropagationPass - This pass propagates information about conditional -// expressions through the program, allowing it to eliminate conditional -// branches in some cases. -// -FunctionPass *createCondPropagationPass(); - -//===----------------------------------------------------------------------===// -// // TailDuplication - Eliminate unconditional branches through controlled code // duplication, creating simpler CFG structures. // Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt?rev=86810&r1=86809&r2=86810&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Tue Nov 10 23:56:35 2009 @@ -3,7 +3,6 @@ ADCE.cpp BasicBlockPlacement.cpp CodeGenPrepare.cpp - CondPropagate.cpp ConstantProp.cpp DCE.cpp DeadStoreElimination.cpp Removed: llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp?rev=86809&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp (removed) @@ -1,289 +0,0 @@ -//===-- CondPropagate.cpp - Propagate Conditional Expressions -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This pass propagates information about conditional expressions through the -// program, allowing it to eliminate conditional branches in some cases. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "condprop" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Instructions.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/Pass.h" -#include "llvm/Type.h" -#include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/Transforms/Utils/Local.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/SmallVector.h" -using namespace llvm; - -STATISTIC(NumBrThread, "Number of CFG edges threaded through branches"); -STATISTIC(NumSwThread, "Number of CFG edges threaded through switches"); - -namespace { - struct CondProp : public FunctionPass { - static char ID; // Pass identification, replacement for typeid - CondProp() : FunctionPass(&ID) {} - - virtual bool runOnFunction(Function &F); - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequiredID(BreakCriticalEdgesID); - //AU.addRequired(); - } - - private: - bool MadeChange; - SmallVector DeadBlocks; - void SimplifyBlock(BasicBlock *BB); - void SimplifyPredecessors(BranchInst *BI); - void SimplifyPredecessors(SwitchInst *SI); - void RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB); - bool RevectorBlockTo(BasicBlock *FromBB, Value *Cond, BranchInst *BI); - }; -} - -char CondProp::ID = 0; -static RegisterPass X("condprop", "Conditional Propagation"); - -FunctionPass *llvm::createCondPropagationPass() { - return new CondProp(); -} - -bool CondProp::runOnFunction(Function &F) { - bool EverMadeChange = false; - DeadBlocks.clear(); - - // While we are simplifying blocks, keep iterating. - do { - MadeChange = false; - for (Function::iterator BB = F.begin(), E = F.end(); BB != E;) - SimplifyBlock(BB++); - EverMadeChange = EverMadeChange || MadeChange; - } while (MadeChange); - - if (EverMadeChange) { - while (!DeadBlocks.empty()) { - BasicBlock *BB = DeadBlocks.back(); DeadBlocks.pop_back(); - DeleteDeadBlock(BB); - } - } - return EverMadeChange; -} - -void CondProp::SimplifyBlock(BasicBlock *BB) { - if (BranchInst *BI = dyn_cast(BB->getTerminator())) { - // If this is a conditional branch based on a phi node that is defined in - // this block, see if we can simplify predecessors of this block. - if (BI->isConditional() && isa(BI->getCondition()) && - cast(BI->getCondition())->getParent() == BB) - SimplifyPredecessors(BI); - - } else if (SwitchInst *SI = dyn_cast(BB->getTerminator())) { - if (isa(SI->getCondition()) && - cast(SI->getCondition())->getParent() == BB) - SimplifyPredecessors(SI); - } - - // If possible, simplify the terminator of this block. - if (ConstantFoldTerminator(BB)) - MadeChange = true; - - // If this block ends with an unconditional branch and the only successor has - // only this block as a predecessor, merge the two blocks together. - if (BranchInst *BI = dyn_cast(BB->getTerminator())) - if (BI->isUnconditional() && BI->getSuccessor(0)->getSinglePredecessor() && - BB != BI->getSuccessor(0)) { - BasicBlock *Succ = BI->getSuccessor(0); - - // If Succ has any PHI nodes, they are all single-entry PHI's. Eliminate - // them. - FoldSingleEntryPHINodes(Succ); - - // Remove BI. - BI->eraseFromParent(); - - // Move over all of the instructions. - BB->getInstList().splice(BB->end(), Succ->getInstList()); - - // Any phi nodes that had entries for Succ now have entries from BB. - Succ->replaceAllUsesWith(BB); - - // Succ is now dead, but we cannot delete it without potentially - // invalidating iterators elsewhere. Just insert an unreachable - // instruction in it and delete this block later on. - new UnreachableInst(BB->getContext(), Succ); - DeadBlocks.push_back(Succ); - MadeChange = true; - } -} - -// SimplifyPredecessors(branches) - We know that BI is a conditional branch -// based on a PHI node defined in this block. If the phi node contains constant -// operands, then the blocks corresponding to those operands can be modified to -// jump directly to the destination instead of going through this block. -void CondProp::SimplifyPredecessors(BranchInst *BI) { - // TODO: We currently only handle the most trival case, where the PHI node has - // one use (the branch), and is the only instruction besides the branch and dbg - // intrinsics in the block. - PHINode *PN = cast(BI->getCondition()); - - if (PN->getNumIncomingValues() == 1) { - // Eliminate single-entry PHI nodes. - FoldSingleEntryPHINodes(PN->getParent()); - return; - } - - - if (!PN->hasOneUse()) return; - - BasicBlock *BB = BI->getParent(); - if (&*BB->begin() != PN) - return; - BasicBlock::iterator BBI = BB->begin(); - BasicBlock::iterator BBE = BB->end(); - while (BBI != BBE && isa(++BBI)) /* empty */; - if (&*BBI != BI) - return; - - // Ok, we have this really simple case, walk the PHI operands, looking for - // constants. Walk from the end to remove operands from the end when - // possible, and to avoid invalidating "i". - for (unsigned i = PN->getNumIncomingValues(); i != 0; --i) { - Value *InVal = PN->getIncomingValue(i-1); - if (!RevectorBlockTo(PN->getIncomingBlock(i-1), InVal, BI)) - continue; - - ++NumBrThread; - - // If there were two predecessors before this simplification, or if the - // PHI node contained all the same value except for the one we just - // substituted, the PHI node may be deleted. Don't iterate through it the - // last time. - if (BI->getCondition() != PN) return; - } -} - -// SimplifyPredecessors(switch) - We know that SI is switch based on a PHI node -// defined in this block. If the phi node contains constant operands, then the -// blocks corresponding to those operands can be modified to jump directly to -// the destination instead of going through this block. -void CondProp::SimplifyPredecessors(SwitchInst *SI) { - // TODO: We currently only handle the most trival case, where the PHI node has - // one use (the branch), and is the only instruction besides the branch and - // dbg intrinsics in the block. - PHINode *PN = cast(SI->getCondition()); - if (!PN->hasOneUse()) return; - - BasicBlock *BB = SI->getParent(); - if (&*BB->begin() != PN) - return; - BasicBlock::iterator BBI = BB->begin(); - BasicBlock::iterator BBE = BB->end(); - while (BBI != BBE && isa(++BBI)) /* empty */; - if (&*BBI != SI) - return; - - // Ok, we have this really simple case, walk the PHI operands, looking for - // constants. Walk from the end to remove operands from the end when - // possible, and to avoid invalidating "i". - for (unsigned i = PN->getNumIncomingValues(); i != 0; --i) - if (ConstantInt *CI = dyn_cast(PN->getIncomingValue(i-1))) { - BasicBlock *PredBB = PN->getIncomingBlock(i-1); - if (isa(PredBB->getTerminator())) { - // If we have a constant, forward the edge from its current to its - // ultimate destination. - unsigned DestCase = SI->findCaseValue(CI); - RevectorBlockTo(PredBB, SI->getSuccessor(DestCase)); - ++NumSwThread; - - // If there were two predecessors before this simplification, or if the - // PHI node contained all the same value except for the one we just - // substituted, the PHI node may be deleted. Don't iterate through it the - // last time. - if (SI->getCondition() != PN) return; - } - } -} - - -// RevectorBlockTo - Revector the unconditional branch at the end of FromBB to -// the ToBB block, which is one of the successors of its current successor. -void CondProp::RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB) { - BranchInst *FromBr = cast(FromBB->getTerminator()); - assert(FromBr->isUnconditional() && "FromBB should end with uncond br!"); - - // Get the old block we are threading through. - BasicBlock *OldSucc = FromBr->getSuccessor(0); - - // OldSucc had multiple successors. If ToBB has multiple predecessors, then - // the edge between them would be critical, which we already took care of. - // If ToBB has single operand PHI node then take care of it here. - FoldSingleEntryPHINodes(ToBB); - - // Update PHI nodes in OldSucc to know that FromBB no longer branches to it. - OldSucc->removePredecessor(FromBB); - - // Change FromBr to branch to the new destination. - FromBr->setSuccessor(0, ToBB); - - MadeChange = true; -} - -bool CondProp::RevectorBlockTo(BasicBlock *FromBB, Value *Cond, BranchInst *BI){ - BranchInst *FromBr = cast(FromBB->getTerminator()); - if (!FromBr->isUnconditional()) - return false; - - // Get the old block we are threading through. - BasicBlock *OldSucc = FromBr->getSuccessor(0); - - // If the condition is a constant, simply revector the unconditional branch at - // the end of FromBB to one of the successors of its current successor. - if (ConstantInt *CB = dyn_cast(Cond)) { - BasicBlock *ToBB = BI->getSuccessor(CB->isZero()); - - // OldSucc had multiple successors. If ToBB has multiple predecessors, then - // the edge between them would be critical, which we already took care of. - // If ToBB has single operand PHI node then take care of it here. - FoldSingleEntryPHINodes(ToBB); - - // Update PHI nodes in OldSucc to know that FromBB no longer branches to it. - OldSucc->removePredecessor(FromBB); - - // Change FromBr to branch to the new destination. - FromBr->setSuccessor(0, ToBB); - } else { - BasicBlock *Succ0 = BI->getSuccessor(0); - // Do not perform transform if the new destination has PHI nodes. The - // transform will add new preds to the PHI's. - if (isa(Succ0->begin())) - return false; - - BasicBlock *Succ1 = BI->getSuccessor(1); - if (isa(Succ1->begin())) - return false; - - // Insert the new conditional branch. - BranchInst::Create(Succ0, Succ1, Cond, FromBr); - - FoldSingleEntryPHINodes(Succ0); - FoldSingleEntryPHINodes(Succ1); - - // Update PHI nodes in OldSucc to know that FromBB no longer branches to it. - OldSucc->removePredecessor(FromBB); - - // Delete the old branch. - FromBr->eraseFromParent(); - } - - MadeChange = true; - return true; -} Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=86810&r1=86809&r2=86810&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Tue Nov 10 23:56:35 2009 @@ -26,10 +26,6 @@ unwrap(PM)->add(createCFGSimplificationPass()); } -void LLVMAddCondPropagationPass(LLVMPassManagerRef PM) { - unwrap(PM)->add(createCondPropagationPass()); -} - void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createDeadStoreEliminationPass()); } From sabre at nondot.org Wed Nov 11 00:42:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 00:42:11 -0600 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html Message-ID: <200911110642.nAB6gBr4023978@zion.cs.uiuc.edu> Changes in directory llvm-www: OpenProjects.html updated: 1.55 -> 1.56 --- Log message: logo done. --- Diffs of the changes: (+1 -2) OpenProjects.html | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm-www/OpenProjects.html diff -u llvm-www/OpenProjects.html:1.55 llvm-www/OpenProjects.html:1.56 --- llvm-www/OpenProjects.html:1.55 Tue Nov 10 23:24:12 2009 +++ llvm-www/OpenProjects.html Wed Nov 11 00:41:50 2009 @@ -475,7 +475,6 @@ opt crashes, use bugpoint to reduce the test case and post it to a website or mailing list. Repeat ad infinitum.
  • -
  • Design a simple, recognizable logo.
  • Add sandbox features to the Interpreter: catch invalid memory accesses, potentially unsafe operations (access via arbitrary memory pointer) etc.
  • @@ -501,7 +500,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
    - Last modified: $Date: 2009/11/11 05:24:12 $ + Last modified: $Date: 2009/11/11 06:41:50 $ From evan.cheng at apple.com Wed Nov 11 01:05:38 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Nov 2009 23:05:38 -0800 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> References: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> Message-ID: <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> Is this done during OptimizeThumb2JumpTables? Then I don't think that would work. It will mess up constant island placements. Perhaps this has to be done before the constant islands part? Or even in the bb placement optimization pass (which should be safe to turn on for ARM now)? Evan On Nov 10, 2009, at 6:47 PM, Jim Grosbach wrote: > Author: grosbach > Date: Tue Nov 10 20:47:19 2009 > New Revision: 86791 > > URL: http://llvm.org/viewvc/llvm-project?rev=86791&view=rev > Log: > > The TBB and TBH instructions for Thumb2 are really handy for jump > tables, but > can only branch forward. To best take advantage of them, we'd like > to adjust > the basic blocks around a bit when reasonable. This patch puts > basics in place > to do that, with a super-simple algorithm for backwards jump table > targets that > creates a new branch after the jump table which branches backwards. > Real > heuristics for reordering blocks or other modifications rather than > inserting > branches will follow. > > > Modified: > llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp > > Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86791&r1=86790&r2=86791&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Nov 10 > 20:47:19 2009 > @@ -31,6 +31,7 @@ > #include "llvm/ADT/SmallVector.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/Statistic.h" > +#include "llvm/Support/CommandLine.h" > #include > using namespace llvm; > > @@ -42,6 +43,12 @@ > STATISTIC(NumT2CPShrunk, "Number of Thumb2 constantpool instructions > shrunk"); > STATISTIC(NumT2BrShrunk, "Number of Thumb2 immediate branches > shrunk"); > STATISTIC(NumCBZ, "Number of CBZ / CBNZ formed"); > +STATISTIC(NumJTMoved, "Number of jump table destination blocks > moved"); > + > + > +static cl::opt > +AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init > (false), > + cl::desc("Adjust basic block layout to better use TB > [BH]")); > > namespace { > /// ARMConstantIslands - Due to limited PC-relative displacements, > ARM > @@ -202,6 +209,8 @@ > bool OptimizeThumb2Instructions(MachineFunction &MF); > bool OptimizeThumb2Branches(MachineFunction &MF); > bool OptimizeThumb2JumpTables(MachineFunction &MF); > + MachineBasicBlock *AdjustJTTargetBlockForward(MachineBasicBlock > *BB, > + MachineBasicBlock > *JTBB); > > unsigned GetOffsetOf(MachineInstr *MI) const; > void dumpBBs(); > @@ -1560,7 +1569,7 @@ > > // FIXME: After the tables are shrunk, can we get rid some of the > // constantpool tables? > - const MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); > + MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); > const std::vector &JT = MJTI->getJumpTables > (); > for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) { > MachineInstr *MI = T2JumpTables[i]; > @@ -1571,10 +1580,33 @@ > unsigned JTI = JTOP.getIndex(); > assert(JTI < JT.size()); > > - bool ByteOk = true; > - bool HalfWordOk = true; > + // We prefer if target blocks for the jump table come after the > jump > + // instruction so we can use TB[BH]. Loop through the target > blocks > + // and try to adjust them such that that's true. > unsigned JTOffset = GetOffsetOf(MI) + 4; > const std::vector &JTBBs = JT[JTI].MBBs; > + if (AdjustJumpTableBlocks) { > + for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { > + MachineBasicBlock *MBB = JTBBs[j]; > + unsigned DstOffset = BBOffsets[MBB->getNumber()]; > + > + if (DstOffset < JTOffset) { > + // The destination precedes the switch. Try to move the > block forward > + // so we have a positive offset. > + MachineBasicBlock *NewBB = > + AdjustJTTargetBlockForward(MBB, MI->getParent()); > + if (NewBB) { > + MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); > + JTOffset = GetOffsetOf(MI) + 4; > + DstOffset = BBOffsets[MBB->getNumber()]; > + } > + } > + } > + } > + > + bool ByteOk = true; > + bool HalfWordOk = true; > + JTOffset = GetOffsetOf(MI) + 4; > for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { > MachineBasicBlock *MBB = JTBBs[j]; > unsigned DstOffset = BBOffsets[MBB->getNumber()]; > @@ -1660,3 +1692,64 @@ > > return MadeChange; > } > + > +MachineBasicBlock *ARMConstantIslands:: > +AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock > *JTBB) > +{ > + MachineFunction &MF = *BB->getParent(); > + > + // FIXME: For now, instead of moving the block, we'll create a > new block > + // immediate following the jump that's an unconditional branch to > the > + // actual target. This is obviously not what we want for a real > solution, > + // but it's useful for proof of concept, and it may be a useful > fallback > + // later for cases where we otherwise can't move a block. > + > + // Create a new MBB for the code after the jump BB. > + MachineBasicBlock *NewBB = > + MF.CreateMachineBasicBlock(JTBB->getBasicBlock()); > + MachineFunction::iterator MBBI = JTBB; ++MBBI; > + MF.insert(MBBI, NewBB); > + > + // Add an unconditional branch from NewBB to BB. > + // There doesn't seem to be meaningful DebugInfo available; this > doesn't > + // correspond directly to anything in the source. > + assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); > + BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get > (ARM::t2B)).addMBB(BB); > + > + // Update the CFG. > + NewBB->addSuccessor(BB); > + JTBB->removeSuccessor(BB); > + JTBB->addSuccessor(NewBB); > + > + // Update internal data structures to account for the newly > inserted MBB. > + // This is almost the same as UpdateForInsertedWaterBlock, except > that > + // the Water goes after OrigBB, not NewBB. > + MF.RenumberBlocks(NewBB); > + > + // Insert a size into BBSizes to align it properly with the (newly > + // renumbered) block numbers. > + BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); > + > + // Likewise for BBOffsets. > + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); > + > + // Figure out how large the first NewMBB is. > + unsigned NewBBSize = 0; > + for (MachineBasicBlock::iterator I = NewBB->begin(), E = NewBB- > >end(); > + I != E; ++I) > + NewBBSize += TII->GetInstSizeInBytes(I); > + > + unsigned NewBBI = NewBB->getNumber(); > + unsigned JTBBI = JTBB->getNumber(); > + // Set the size of NewBB in BBSizes. > + BBSizes[NewBBI] = NewBBSize; > + > + // ...and adjust BBOffsets for NewBB accordingly. > + BBOffsets[NewBBI] = BBOffsets[JTBBI] + BBSizes[JTBBI]; > + > + // All BBOffsets following these blocks must be modified. > + AdjustBBOffsetsAfter(NewBB, 4); > + > + ++NumJTMoved; > + return NewBB; > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Wed Nov 11 01:11:03 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 07:11:03 -0000 Subject: [llvm-commits] [llvm] r86814 - in /llvm/trunk/test/CodeGen/X86: loop-strength-reduce2.ll loop-strength-reduce3.ll loop-strength-reduce5.ll loop-strength-reduce6.ll Message-ID: <200911110711.nAB7B3kx024811@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 11 01:11:02 2009 New Revision: 86814 URL: http://llvm.org/viewvc/llvm-project?rev=86814&view=rev Log: Add nounwind. Modified: llvm/trunk/test/CodeGen/X86/loop-strength-reduce2.ll llvm/trunk/test/CodeGen/X86/loop-strength-reduce3.ll llvm/trunk/test/CodeGen/X86/loop-strength-reduce5.ll llvm/trunk/test/CodeGen/X86/loop-strength-reduce6.ll Modified: llvm/trunk/test/CodeGen/X86/loop-strength-reduce2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-strength-reduce2.ll?rev=86814&r1=86813&r2=86814&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-strength-reduce2.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-strength-reduce2.ll Wed Nov 11 01:11:02 2009 @@ -4,7 +4,7 @@ @flags2 = internal global [8193 x i8] zeroinitializer, align 32 ; <[8193 x i8]*> [#uses=1] -define void @test(i32 %k, i32 %i) { +define void @test(i32 %k, i32 %i) nounwind { entry: %k_addr.012 = shl i32 %i, 1 ; [#uses=1] %tmp14 = icmp sgt i32 %k_addr.012, 8192 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/loop-strength-reduce3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-strength-reduce3.ll?rev=86814&r1=86813&r2=86814&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-strength-reduce3.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-strength-reduce3.ll Wed Nov 11 01:11:02 2009 @@ -1,7 +1,7 @@ ; RUN: llc < %s -march=x86 | grep cmp | grep 240 ; RUN: llc < %s -march=x86 | grep inc | count 1 -define i32 @foo(i32 %A, i32 %B, i32 %C, i32 %D) { +define i32 @foo(i32 %A, i32 %B, i32 %C, i32 %D) nounwind { entry: %tmp2955 = icmp sgt i32 %C, 0 ; [#uses=1] br i1 %tmp2955, label %bb26.outer.us, label %bb40.split Modified: llvm/trunk/test/CodeGen/X86/loop-strength-reduce5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-strength-reduce5.ll?rev=86814&r1=86813&r2=86814&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-strength-reduce5.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-strength-reduce5.ll Wed Nov 11 01:11:02 2009 @@ -3,7 +3,7 @@ @X = weak global i16 0 ; [#uses=1] @Y = weak global i16 0 ; [#uses=1] -define void @foo(i32 %N) { +define void @foo(i32 %N) nounwind { entry: %tmp1019 = icmp sgt i32 %N, 0 ; [#uses=1] br i1 %tmp1019, label %bb, label %return Modified: llvm/trunk/test/CodeGen/X86/loop-strength-reduce6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-strength-reduce6.ll?rev=86814&r1=86813&r2=86814&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-strength-reduce6.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-strength-reduce6.ll Wed Nov 11 01:11:02 2009 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=x86-64 | not grep inc -define fastcc i32 @decodeMP3(i32 %isize, i32* %done) { +define fastcc i32 @decodeMP3(i32 %isize, i32* %done) nounwind { entry: br i1 false, label %cond_next191, label %cond_true189 From baldrick at free.fr Wed Nov 11 07:43:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 Nov 2009 13:43:11 -0000 Subject: [llvm-commits] [dragonegg] r86838 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200911111343.nABDhBfh021593@zion.cs.uiuc.edu> Author: baldrick Date: Wed Nov 11 07:43:10 2009 New Revision: 86838 URL: http://llvm.org/viewvc/llvm-project?rev=86838&view=rev Log: It seems that the intent is that llvm.invariant.start should not require a corresponding call to llvm.invariant.end. The fact that this doesn't work is an LLVM bug... So stop trying to output calls to llvm.invariant.end all over the place. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=86838&r1=86837&r2=86838&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Nov 11 07:43:10 2009 @@ -763,26 +763,6 @@ typedef SmallVector, 8> TreeVector; typedef SmallVector, 8> ValueVector; -/// EndInvariantRegions - Output a call to llvm.invariant.end for each call -/// to llvm.invariant.start recorded in InvariantRegions. -void TreeToLLVM::EndInvariantRegions() { - if (InvariantRegions.empty()) - return; - - Value *Ops[3]; - Value *IEnd = Intrinsic::getDeclaration(TheModule,Intrinsic::invariant_end); - for (unsigned i = 0, e = InvariantRegions.size(); i < e; ++i) { - CallInst *CI = InvariantRegions[i]; - Ops[0] = CI; - Ops[1] = CI->getOperand(1); - Ops[2] = CI->getOperand(2); - Builder.CreateCall(IEnd, Ops, Ops + 3); - } - - // Do not clear out InvariantRegions in case the function has multiple exits: - // we need to output calls to llvm.invariant.end before each one. -} - /// PopulatePhiNodes - Populate generated phi nodes with their operands. void TreeToLLVM::PopulatePhiNodes() { PredVector Predecessors; @@ -949,9 +929,6 @@ TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder); TheDebugInfo->EmitFunctionEnd(Builder.GetInsertBlock(), true); } - - EndInvariantRegions(); - if (RetVals.empty()) Builder.CreateRetVoid(); else if (RetVals.size() == 1 && RetVals[0]->getType() == Fn->getReturnType()){ @@ -2128,7 +2105,6 @@ if (UnwindBB) { CreateExceptionValues(); EmitBlock(UnwindBB); - EndInvariantRegions(); abort();//FIXME //FIXME // Fetch and store exception handler. //FIXME Value *Arg = Builder.CreateLoad(ExceptionValue, "eh_ptr"); @@ -2567,7 +2543,6 @@ // after the function to prevent LLVM from thinking that control flow will // fall into the subsequent block. if (gimple_call_flags(stmt) & ECF_NORETURN) { - EndInvariantRegions(); Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); } @@ -4638,7 +4613,6 @@ case BUILT_IN_TRAP: Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::trap)); // Emit an explicit unreachable instruction. - EndInvariantRegions(); Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); return true; @@ -5485,7 +5459,6 @@ Args.push_back(Handler); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, IID), Args.begin(), Args.end()); - EndInvariantRegions(); Result = Builder.CreateUnreachable(); EmitBlock(BasicBlock::Create(Context)); @@ -5699,26 +5672,6 @@ // is called. static const Type *VPTy = Type::getInt8PtrTy(Context); - // In order to simplify the use of llvm.invariant.start/end, generate the - // trampoline initialization code in the entry block. - BasicBlock *EntryBlock = Fn->begin(); - - // Note the current builder position. - BasicBlock *SavedInsertBB = Builder.GetInsertBlock(); - BasicBlock::iterator SavedInsertPoint = Builder.GetInsertPoint(); - - // Pop the entry block terminator. There may not be a terminator if the entry - // block was not yet finished. - Instruction *Terminator = EntryBlock->getTerminator(); - assert(((SavedInsertBB != EntryBlock && Terminator) || - (SavedInsertPoint == EntryBlock->end() && !Terminator)) && - "Insertion point doesn't make sense!"); - if (Terminator) - Terminator->removeFromParent(); - - // Point the builder at the end of the entry block. - Builder.SetInsertPoint(EntryBlock); - // Create a stack temporary to hold the trampoline machine code. const Type *TrampType = ArrayType::get(Type::getInt8Ty(Context), TRAMPOLINE_SIZE); @@ -5755,16 +5708,7 @@ Intr = Intrinsic::getDeclaration(TheModule, Intrinsic::invariant_start); Ops[0] = ConstantInt::get(Type::getInt64Ty(Context), TRAMPOLINE_SIZE); Ops[1] = Builder.CreateBitCast(Tramp, VPTy); - CallInst *InvStart = Builder.CreateCall(Intr, Ops, Ops + 2); - InvariantRegions.push_back(InvStart); - - // Restore the entry block terminator. - if (Terminator) - EntryBlock->getInstList().push_back(Terminator); - - // Restore the builder insertion point. - if (SavedInsertBB != EntryBlock) - Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); + Builder.CreateCall(Intr, Ops, Ops + 2); return true; } Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=86838&r1=86837&r2=86838&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Wed Nov 11 07:43:10 2009 @@ -357,10 +357,6 @@ /// LocalDecls - Map from local declarations to their associated LLVM values. DenseMap > LocalDecls; - /// InvariantRegions - Calls to llvm.invariant.start for which a corresponding - /// call to llvm.invariant.end needs to be generated at function exit points. - SmallVector InvariantRegions; - /// PendingPhis - Phi nodes which have not yet been populated with operands. SmallVector PendingPhis; @@ -473,15 +469,11 @@ /// StartFunctionBody - Start the emission of 'fndecl', outputing all /// declarations for parameters and setting things up. void StartFunctionBody(); - + /// FinishFunctionBody - Once the body of the function has been emitted, this /// cleans up and returns the result function. Function *FinishFunctionBody(); - /// EndInvariantRegions - Output a call to llvm.invariant.end for each call - /// of llvm.invariant.start recorded in InvariantRegions. - void EndInvariantRegions(); - /// PopulatePhiNodes - Populate generated phi nodes with their operands. void PopulatePhiNodes(); From baldrick at free.fr Wed Nov 11 09:34:13 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 Nov 2009 15:34:13 -0000 Subject: [llvm-commits] [llvm] r86840 - in /llvm/trunk: include/llvm/IntrinsicInst.h lib/Transforms/Utils/Local.cpp test/Transforms/InstCombine/invariant.ll Message-ID: <200911111534.nABFYEd0025670@zion.cs.uiuc.edu> Author: baldrick Date: Wed Nov 11 09:34:13 2009 New Revision: 86840 URL: http://llvm.org/viewvc/llvm-project?rev=86840&view=rev Log: Don't trivially delete unused calls to llvm.invariant.start. This allows llvm.invariant.start to be used without necessarily being paired with a call to llvm.invariant.end. If you run the entire optimization pipeline then such calls are in fact deleted (adce does it), but that's actually a good thing since we probably do want them to be zapped late in the game. There should really be an integration test that checks that the llvm.invariant.start call lasts long enough that all passes that do interesting things with it get to do their stuff before it is deleted. But since no passes do anything interesting with it yet this will have to wait for later. Added: llvm/trunk/test/Transforms/InstCombine/invariant.ll Modified: llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=86840&r1=86839&r2=86840&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Wed Nov 11 09:34:13 2009 @@ -320,6 +320,28 @@ } }; + /// MemoryUseIntrinsic - This is the common base class for the memory use + /// marker intrinsics. + /// + struct MemoryUseIntrinsic : public IntrinsicInst { + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const MemoryUseIntrinsic *) { return true; } + static inline bool classof(const IntrinsicInst *I) { + switch (I->getIntrinsicID()) { + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::invariant_start: + case Intrinsic::invariant_end: + return true; + default: return false; + } + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } + }; + } #endif Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=86840&r1=86839&r2=86840&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Nov 11 09:34:13 2009 @@ -252,6 +252,9 @@ // We don't want debug info removed by anything this general. if (isa(I)) return false; + // Likewise for memory use markers. + if (isa(I)) return false; + if (!I->mayHaveSideEffects()) return true; // Special case intrinsics that "may have side effects" but can be deleted Added: llvm/trunk/test/Transforms/InstCombine/invariant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/invariant.ll?rev=86840&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/invariant.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/invariant.ll Wed Nov 11 09:34:13 2009 @@ -0,0 +1,16 @@ +; Test to make sure unused llvm.invariant.start calls are not trivially eliminated +; RUN: opt < %s -instcombine -S | FileCheck %s + +declare void @g(i8*) + +declare { }* @llvm.invariant.start(i64, i8* nocapture) nounwind readonly + +define i8 @f() { + %a = alloca i8 ; [#uses=4] + store i8 0, i8* %a + %i = call { }* @llvm.invariant.start(i64 1, i8* %a) ; <{ }*> [#uses=0] + ; CHECK: call { }* @llvm.invariant.start + call void @g(i8* %a) + %r = load i8* %a ; [#uses=1] + ret i8 %r +} From grosbach at apple.com Wed Nov 11 10:40:28 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Nov 2009 08:40:28 -0800 Subject: [llvm-commits] [llvm] r86404 - in /llvm/trunk/lib/Target/ARM: ARMAddressingModes.h ARMISelDAGToDAG.cpp ARMInstrInfo.td AsmPrinter/ARMAsmPrinter.cpp NEONPreAllocPass.cpp In-Reply-To: <90BAE2B3-491D-4D6F-BA26-4A9CD2E54B84@apple.com> References: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> <90BAE2B3-491D-4D6F-BA26-4A9CD2E54B84@apple.com> Message-ID: <07E25920-8744-4E1E-B020-292B6B32984A@apple.com> On Nov 10, 2009, at 1:27 AM, Evan Cheng wrote: > > On Nov 7, 2009, at 1:25 PM, Jim Grosbach wrote: > >> >> >> bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N, >> SDValue &Addr, SDValue &Update, >> - SDValue &Opc) { >> + SDValue &Opc, SDValue >> &Align) { >> Addr = N; >> // Default to no writeback. >> Update = CurDAG->getRegister(0, MVT::i32); >> Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), MVT::i32); >> + // Default to no alignment. >> + Align = CurDAG->getTargetConstant(0, MVT::i32); >> return true; >> } > > Shouldn't we be able to transfer the alignment on the LoadSDNode / > StoreSDNode to Align (capped at 64 / 128 for 64-bit / 128-bit memory > operations)? Potentially. I'm concerned about stack objects in frames we don't dynamically align, however. That could result in aligned load/stores of objects w/o guaranteed alignment, and I wanted to avoid that. I've been wondering about the best approach for that. We could do the alignment anyway and consider the additional dynamic alignment situations (VLAs and such) to be optimization opportunities. Or we could let the user specify alignment as an optional operand to the NEON builtins. That doesn't help with any auto-vectorizing stuff we may do, however. I tend to prefer the first option. What do you think? > > Evan > >> >> @@ -1008,8 +1010,8 @@ >> SDNode *N = Op.getNode(); >> DebugLoc dl = N->getDebugLoc(); >> >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc)) >> + SDValue MemAddr, MemUpdate, MemOpc, Align; >> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc, Align)) >> return NULL; >> >> SDValue Chain = N->getOperand(0); >> @@ -1034,10 +1036,10 @@ >> >> if (is64BitVector) { >> unsigned Opc = DOpcodes[OpcodeIndex]; >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, >> Chain }; >> std::vector ResTys(NumVecs, VT); >> ResTys.push_back(MVT::Other); >> - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); >> } >> >> EVT RegVT = GetNEONSubregVT(VT); >> @@ -1045,10 +1047,10 @@ >> // Quad registers are directly supported for VLD2, >> // loading 2 pairs of D regs. >> unsigned Opc = QOpcodes0[OpcodeIndex]; >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, >> Chain }; >> std::vector ResTys(4, VT); >> ResTys.push_back(MVT::Other); >> - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); >> Chain = SDValue(VLd, 4); >> >> // Combine the even and odd subregs to produce the result. >> @@ -1069,14 +1071,15 @@ >> >> // Load the even subregs. >> unsigned Opc = QOpcodes0[OpcodeIndex]; >> - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); >> + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Align, >> Chain }; >> + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 5); >> Chain = SDValue(VLdA, NumVecs+1); >> >> // Load the odd subregs. >> Opc = QOpcodes1[OpcodeIndex]; >> - const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, >> MemOpc, Chain }; >> - SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); >> + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, >> MemOpc, >> + Align, Chain }; >> + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 5); >> Chain = SDValue(VLdB, NumVecs+1); >> >> // Combine the even and odd subregs to produce the result. >> @@ -1096,8 +1099,8 @@ >> SDNode *N = Op.getNode(); >> DebugLoc dl = N->getDebugLoc(); >> >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc)) >> + SDValue MemAddr, MemUpdate, MemOpc, Align; >> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc, Align)) >> return NULL; >> >> SDValue Chain = N->getOperand(0); >> @@ -1124,13 +1127,14 @@ >> Ops.push_back(MemAddr); >> Ops.push_back(MemUpdate); >> Ops.push_back(MemOpc); >> + Ops.push_back(Align); >> >> if (is64BitVector) { >> unsigned Opc = DOpcodes[OpcodeIndex]; >> for (unsigned Vec = 0; Vec < NumVecs; ++Vec) >> Ops.push_back(N->getOperand(Vec+3)); >> Ops.push_back(Chain); >> - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), >> NumVecs+4); >> + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), >> NumVecs+5); >> } >> >> EVT RegVT = GetNEONSubregVT(VT); >> @@ -1145,7 +1149,7 @@ >> N->getOperand(Vec >> +3))); >> } >> Ops.push_back(Chain); >> - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), >> 8); >> + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), >> 9); >> } >> >> // Otherwise, quad registers are stored with two separate >> instructions, >> @@ -1161,18 +1165,18 @@ >> Ops.push_back(Chain); >> unsigned Opc = QOpcodes0[OpcodeIndex]; >> SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType >> (), >> - MVT::Other, Ops.data(), >> NumVecs+4); >> + MVT::Other, Ops.data(), >> NumVecs+5); >> Chain = SDValue(VStA, 1); >> >> // Store the odd subregs. >> Ops[0] = SDValue(VStA, 0); // MemAddr >> for (unsigned Vec = 0; Vec < NumVecs; ++Vec) >> - Ops[Vec+3] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, >> dl, RegVT, >> + Ops[Vec+4] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, >> dl, RegVT, >> N->getOperand(Vec+3)); >> - Ops[NumVecs+3] = Chain; >> + Ops[NumVecs+4] = Chain; >> Opc = QOpcodes1[OpcodeIndex]; >> SDNode *VStB = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType >> (), >> - MVT::Other, Ops.data(), >> NumVecs+4); >> + MVT::Other, Ops.data(), >> NumVecs+5); >> Chain = SDValue(VStB, 1); >> ReplaceUses(SDValue(N, 0), Chain); >> return NULL; >> @@ -1186,8 +1190,8 @@ >> SDNode *N = Op.getNode(); >> DebugLoc dl = N->getDebugLoc(); >> >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc)) >> + SDValue MemAddr, MemUpdate, MemOpc, Align; >> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc, Align)) >> return NULL; >> >> SDValue Chain = N->getOperand(0); >> @@ -1224,6 +1228,7 @@ >> Ops.push_back(MemAddr); >> Ops.push_back(MemUpdate); >> Ops.push_back(MemOpc); >> + Ops.push_back(Align); >> >> unsigned Opc = 0; >> if (is64BitVector) { >> >> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=86404&r1=86403&r2=86404&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sat Nov 7 15:25:39 >> 2009 >> @@ -340,9 +340,9 @@ >> // addrmode6 := reg with optional writeback >> // >> def addrmode6 : Operand, >> - ComplexPattern { >> + ComplexPattern { >> let PrintMethod = "printAddrMode6Operand"; >> - let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm); >> + let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm); >> } >> >> // addrmodepc := pc + reg >> >> Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=86404&r1=86403&r2=86404&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Nov >> 7 15:25:39 2009 >> @@ -638,9 +638,17 @@ >> const MachineOperand &MO1 = MI->getOperand(Op); >> const MachineOperand &MO2 = MI->getOperand(Op+1); >> const MachineOperand &MO3 = MI->getOperand(Op+2); >> + const MachineOperand &MO4 = MI->getOperand(Op+3); >> >> - // FIXME: No support yet for specifying alignment. >> - O << "[" << getRegisterName(MO1.getReg()) << "]"; >> + O << "[" << getRegisterName(MO1.getReg()); >> + if (MO4.getImm()) { >> + if (Subtarget->isTargetDarwin()) >> + O << ", :"; >> + else >> + O << " @"; >> + O << MO4.getImm(); >> + } >> + O << "]"; >> >> if (ARM_AM::getAM6WBFlag(MO3.getImm())) { >> if (MO2.getReg() == 0) >> >> Modified: llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp?rev=86404&r1=86403&r2=86404&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Sat Nov 7 >> 15:25:39 2009 >> @@ -177,20 +177,20 @@ >> case ARM::VST2LNd8: >> case ARM::VST2LNd16: >> case ARM::VST2LNd32: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 2; >> return true; >> >> case ARM::VST2q8: >> case ARM::VST2q16: >> case ARM::VST2q32: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 4; >> return true; >> >> case ARM::VST2LNq16a: >> case ARM::VST2LNq32a: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 2; >> Offset = 0; >> Stride = 2; >> @@ -198,7 +198,7 @@ >> >> case ARM::VST2LNq16b: >> case ARM::VST2LNq32b: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 2; >> Offset = 1; >> Stride = 2; >> @@ -211,14 +211,14 @@ >> case ARM::VST3LNd8: >> case ARM::VST3LNd16: >> case ARM::VST3LNd32: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 3; >> return true; >> >> case ARM::VST3q8a: >> case ARM::VST3q16a: >> case ARM::VST3q32a: >> - FirstOpnd = 4; >> + FirstOpnd = 5; >> NumRegs = 3; >> Offset = 0; >> Stride = 2; >> @@ -227,7 +227,7 @@ >> case ARM::VST3q8b: >> case ARM::VST3q16b: >> case ARM::VST3q32b: >> - FirstOpnd = 4; >> + FirstOpnd = 5; >> NumRegs = 3; >> Offset = 1; >> Stride = 2; >> @@ -235,7 +235,7 @@ >> >> case ARM::VST3LNq16a: >> case ARM::VST3LNq32a: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 3; >> Offset = 0; >> Stride = 2; >> @@ -243,7 +243,7 @@ >> >> case ARM::VST3LNq16b: >> case ARM::VST3LNq32b: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 3; >> Offset = 1; >> Stride = 2; >> @@ -256,14 +256,14 @@ >> case ARM::VST4LNd8: >> case ARM::VST4LNd16: >> case ARM::VST4LNd32: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 4; >> return true; >> >> case ARM::VST4q8a: >> case ARM::VST4q16a: >> case ARM::VST4q32a: >> - FirstOpnd = 4; >> + FirstOpnd = 5; >> NumRegs = 4; >> Offset = 0; >> Stride = 2; >> @@ -272,7 +272,7 @@ >> case ARM::VST4q8b: >> case ARM::VST4q16b: >> case ARM::VST4q32b: >> - FirstOpnd = 4; >> + FirstOpnd = 5; >> NumRegs = 4; >> Offset = 1; >> Stride = 2; >> @@ -280,7 +280,7 @@ >> >> case ARM::VST4LNq16a: >> case ARM::VST4LNq32a: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 4; >> Offset = 0; >> Stride = 2; >> @@ -288,7 +288,7 @@ >> >> case ARM::VST4LNq16b: >> case ARM::VST4LNq32b: >> - FirstOpnd = 3; >> + FirstOpnd = 4; >> NumRegs = 4; >> Offset = 1; >> Stride = 2; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From grosbach at apple.com Wed Nov 11 11:22:41 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Nov 2009 09:22:41 -0800 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> References: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> Message-ID: Yeah, it definitely should be moved. That's one of the things I'm going to do this morning. We could do it in the placement optimization pass, but I'm a bit hesitant at this point since a fair bit of the information we may use for determining how and whether to make transformations will be target specific. The ranges of the TB[BH] instructions being the most straightforward example. That may be handleable via target hooks or something, though. Once we have a better handle on the specifics of the heuristics, that should be more apparent. Why was the code placement opt unsafe for arm before? I don't recall the history there. -Jim On Nov 10, 2009, at 11:05 PM, Evan Cheng wrote: > Is this done during OptimizeThumb2JumpTables? Then I don't think > that would work. It will mess up constant island placements. Perhaps > this has to be done before the constant islands part? Or even in the > bb placement optimization pass (which should be safe to turn on for > ARM now)? > > Evan > > On Nov 10, 2009, at 6:47 PM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Tue Nov 10 20:47:19 2009 >> New Revision: 86791 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86791&view=rev >> Log: >> >> The TBB and TBH instructions for Thumb2 are really handy for jump >> tables, but >> can only branch forward. To best take advantage of them, we'd like >> to adjust >> the basic blocks around a bit when reasonable. This patch puts >> basics in place >> to do that, with a super-simple algorithm for backwards jump table >> targets that >> creates a new branch after the jump table which branches backwards. >> Real >> heuristics for reordering blocks or other modifications rather than >> inserting >> branches will follow. >> >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> >> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86791&r1=86790&r2=86791&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Nov 10 >> 20:47:19 2009 >> @@ -31,6 +31,7 @@ >> #include "llvm/ADT/SmallVector.h" >> #include "llvm/ADT/STLExtras.h" >> #include "llvm/ADT/Statistic.h" >> +#include "llvm/Support/CommandLine.h" >> #include >> using namespace llvm; >> >> @@ -42,6 +43,12 @@ >> STATISTIC(NumT2CPShrunk, "Number of Thumb2 constantpool >> instructions shrunk"); >> STATISTIC(NumT2BrShrunk, "Number of Thumb2 immediate branches >> shrunk"); >> STATISTIC(NumCBZ, "Number of CBZ / CBNZ formed"); >> +STATISTIC(NumJTMoved, "Number of jump table destination blocks >> moved"); >> + >> + >> +static cl::opt >> +AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, >> cl::init(false), >> + cl::desc("Adjust basic block layout to better use TB >> [BH]")); >> >> namespace { >> /// ARMConstantIslands - Due to limited PC-relative displacements, >> ARM >> @@ -202,6 +209,8 @@ >> bool OptimizeThumb2Instructions(MachineFunction &MF); >> bool OptimizeThumb2Branches(MachineFunction &MF); >> bool OptimizeThumb2JumpTables(MachineFunction &MF); >> + MachineBasicBlock *AdjustJTTargetBlockForward >> (MachineBasicBlock *BB, >> + >> MachineBasicBlock *JTBB); >> >> unsigned GetOffsetOf(MachineInstr *MI) const; >> void dumpBBs(); >> @@ -1560,7 +1569,7 @@ >> >> // FIXME: After the tables are shrunk, can we get rid some of the >> // constantpool tables? >> - const MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); >> + MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); >> const std::vector &JT = MJTI->getJumpTables >> (); >> for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) { >> MachineInstr *MI = T2JumpTables[i]; >> @@ -1571,10 +1580,33 @@ >> unsigned JTI = JTOP.getIndex(); >> assert(JTI < JT.size()); >> >> - bool ByteOk = true; >> - bool HalfWordOk = true; >> + // We prefer if target blocks for the jump table come after >> the jump >> + // instruction so we can use TB[BH]. Loop through the target >> blocks >> + // and try to adjust them such that that's true. >> unsigned JTOffset = GetOffsetOf(MI) + 4; >> const std::vector &JTBBs = JT[JTI].MBBs; >> + if (AdjustJumpTableBlocks) { >> + for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { >> + MachineBasicBlock *MBB = JTBBs[j]; >> + unsigned DstOffset = BBOffsets[MBB->getNumber()]; >> + >> + if (DstOffset < JTOffset) { >> + // The destination precedes the switch. Try to move the >> block forward >> + // so we have a positive offset. >> + MachineBasicBlock *NewBB = >> + AdjustJTTargetBlockForward(MBB, MI->getParent()); >> + if (NewBB) { >> + MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); >> + JTOffset = GetOffsetOf(MI) + 4; >> + DstOffset = BBOffsets[MBB->getNumber()]; >> + } >> + } >> + } >> + } >> + >> + bool ByteOk = true; >> + bool HalfWordOk = true; >> + JTOffset = GetOffsetOf(MI) + 4; >> for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { >> MachineBasicBlock *MBB = JTBBs[j]; >> unsigned DstOffset = BBOffsets[MBB->getNumber()]; >> @@ -1660,3 +1692,64 @@ >> >> return MadeChange; >> } >> + >> +MachineBasicBlock *ARMConstantIslands:: >> +AdjustJTTargetBlockForward(MachineBasicBlock *BB, >> MachineBasicBlock *JTBB) >> +{ >> + MachineFunction &MF = *BB->getParent(); >> + >> + // FIXME: For now, instead of moving the block, we'll create a >> new block >> + // immediate following the jump that's an unconditional branch >> to the >> + // actual target. This is obviously not what we want for a real >> solution, >> + // but it's useful for proof of concept, and it may be a useful >> fallback >> + // later for cases where we otherwise can't move a block. >> + >> + // Create a new MBB for the code after the jump BB. >> + MachineBasicBlock *NewBB = >> + MF.CreateMachineBasicBlock(JTBB->getBasicBlock()); >> + MachineFunction::iterator MBBI = JTBB; ++MBBI; >> + MF.insert(MBBI, NewBB); >> + >> + // Add an unconditional branch from NewBB to BB. >> + // There doesn't seem to be meaningful DebugInfo available; this >> doesn't >> + // correspond directly to anything in the source. >> + assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); >> + BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get >> (ARM::t2B)).addMBB(BB); >> + >> + // Update the CFG. >> + NewBB->addSuccessor(BB); >> + JTBB->removeSuccessor(BB); >> + JTBB->addSuccessor(NewBB); >> + >> + // Update internal data structures to account for the newly >> inserted MBB. >> + // This is almost the same as UpdateForInsertedWaterBlock, >> except that >> + // the Water goes after OrigBB, not NewBB. >> + MF.RenumberBlocks(NewBB); >> + >> + // Insert a size into BBSizes to align it properly with the (newly >> + // renumbered) block numbers. >> + BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); >> + >> + // Likewise for BBOffsets. >> + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); >> + >> + // Figure out how large the first NewMBB is. >> + unsigned NewBBSize = 0; >> + for (MachineBasicBlock::iterator I = NewBB->begin(), E = NewBB- >> >end(); >> + I != E; ++I) >> + NewBBSize += TII->GetInstSizeInBytes(I); >> + >> + unsigned NewBBI = NewBB->getNumber(); >> + unsigned JTBBI = JTBB->getNumber(); >> + // Set the size of NewBB in BBSizes. >> + BBSizes[NewBBI] = NewBBSize; >> + >> + // ...and adjust BBOffsets for NewBB accordingly. >> + BBOffsets[NewBBI] = BBOffsets[JTBBI] + BBSizes[JTBBI]; >> + >> + // All BBOffsets following these blocks must be modified. >> + AdjustBBOffsetsAfter(NewBB, 4); >> + >> + ++NumJTMoved; >> + return NewBB; >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Wed Nov 11 11:37:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 17:37:02 -0000 Subject: [llvm-commits] [llvm] r86846 - /llvm/trunk/lib/VMCore/Verifier.cpp Message-ID: <200911111737.nABHb22o030209@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 11:37:02 2009 New Revision: 86846 URL: http://llvm.org/viewvc/llvm-project?rev=86846&view=rev Log: Reject duplicate case values in a switch, PR5450. Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=86846&r1=86845&r2=86846&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Nov 11 11:37:02 2009 @@ -780,9 +780,13 @@ // Check to make sure that all of the constants in the switch instruction // have the same type as the switched-on value. const Type *SwitchTy = SI.getCondition()->getType(); - for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i) + SmallPtrSet Constants; + for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i) { Assert1(SI.getCaseValue(i)->getType() == SwitchTy, "Switch constants must all be same type as switch value!", &SI); + Assert2(Constants.insert(SI.getCaseValue(i)), + "Duplicate integer as switch case", &SI, SI.getCaseValue(i)); + } visitTerminatorInst(SI); } From bob.wilson at apple.com Wed Nov 11 11:42:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Nov 2009 09:42:41 -0800 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: References: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> Message-ID: <41DF73EA-6ED0-44BB-9084-D8366E11A928@apple.com> On Nov 11, 2009, at 9:22 AM, Jim Grosbach wrote: > > Why was the code placement opt unsafe for arm before? I don't recall > the history there. If I remember correctly, it was running after ARMConstantIslandPass when it is not safe to change the size or position of anything. From sabre at nondot.org Wed Nov 11 11:51:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 17:51:27 -0000 Subject: [llvm-commits] [llvm] r86847 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911111751.nABHpRGM030746@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 11:51:27 2009 New Revision: 86847 URL: http://llvm.org/viewvc/llvm-project?rev=86847&view=rev Log: add a note Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86847&r1=86846&r2=86847&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Wed Nov 11 11:51:27 2009 @@ -1682,3 +1682,31 @@ } //===---------------------------------------------------------------------===// + +IPSCCP does not currently propagate argument dependent constants through +functions where it does not not all of the callers. This includes functions +with normal external linkage as well as templates, C99 inline functions etc. +Specifically, it does nothing to: + +define i32 @test(i32 %x, i32 %y, i32 %z) nounwind { +entry: + %0 = add nsw i32 %y, %z + %1 = mul i32 %0, %x + %2 = mul i32 %y, %z + %3 = add nsw i32 %1, %2 + ret i32 %3 +} + +define i32 @test2() nounwind { +entry: + %0 = call i32 @test(i32 1, i32 2, i32 4) nounwind + ret i32 %0 +} + +It would be interesting extend IPSCCP to be able to handle simple cases like +this, where all of the arguments to a call are constant. Because IPSCCP runs +before inlining, trivial templates and inline functions are not yet inlined. +The results for a function + set of constant arguments should be memoized in a +map. + +//===---------------------------------------------------------------------===// From sabre at nondot.org Wed Nov 11 11:54:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 17:54:02 -0000 Subject: [llvm-commits] [llvm] r86848 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911111754.nABHs2Wn030824@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 11:54:02 2009 New Revision: 86848 URL: http://llvm.org/viewvc/llvm-project?rev=86848&view=rev Log: another const prop failure. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86848&r1=86847&r2=86848&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Wed Nov 11 11:54:02 2009 @@ -1710,3 +1710,12 @@ map. //===---------------------------------------------------------------------===// + +The libcall constant folding stuff should be moved out of SimplifyLibcalls into +libanalysis' constantfolding logic. This would allow IPSCCP to be able to +handle simple things like this: + +static int foo(const char *X) { return strlen(X); } +int bar() { return foo("abcd"); } + +//===---------------------------------------------------------------------===// From gohman at apple.com Wed Nov 11 12:07:16 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:07:16 -0000 Subject: [llvm-commits] [llvm] r86850 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td Message-ID: <200911111807.nABI7HVm031305@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:07:16 2009 New Revision: 86850 URL: http://llvm.org/viewvc/llvm-project?rev=86850&view=rev Log: Use a tab in INT3's asm string, for consistency. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=86850&r1=86849&r2=86850&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Nov 11 12:07:16 2009 @@ -543,7 +543,7 @@ } // Trap -def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>; +def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>; def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>; // PIC base construction. This expands to code that looks like this: From gohman at apple.com Wed Nov 11 12:11:07 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:11:07 -0000 Subject: [llvm-commits] [llvm] r86851 - in /llvm/trunk/lib/Target: Alpha/AlphaInstrInfo.td Blackfin/BlackfinInstrInfo.td MSP430/MSP430InstrInfo.td Sparc/SparcInstrInfo.td XCore/XCoreInstrInfo.td Message-ID: <200911111811.nABIB7iT031446@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:11:07 2009 New Revision: 86851 URL: http://llvm.org/viewvc/llvm-project?rev=86851&view=rev Log: Set isBarrier = 1 on return instructions, as they are control barriers. Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td?rev=86851&r1=86850&r2=86851&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td (original) +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td Wed Nov 11 12:11:07 2009 @@ -391,7 +391,7 @@ def : Pat<(setune GPRC:$X, immUExt8:$Y), (CMPEQi (CMPEQ GPRC:$X, immUExt8:$Y), 0)>; -let isReturn = 1, isTerminator = 1, Ra = 31, Rb = 26, disp = 1, Uses = [R26] in { +let isReturn = 1, isTerminator = 1, isBarrier = 1, Ra = 31, Rb = 26, disp = 1, Uses = [R26] in { def RETDAG : MbrForm< 0x1A, 0x02, (ops), "ret $$31,($$26),1", s_jsr>; //Return from subroutine def RETDAGp : MbrpForm< 0x1A, 0x02, (ops), "ret $$31,($$26),1", [(retflag)], s_jsr>; //Return from subroutine } Modified: llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td?rev=86851&r1=86850&r2=86851&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td Wed Nov 11 12:11:07 2009 @@ -174,6 +174,7 @@ let isReturn = 1, isTerminator = 1, + isBarrier = 1, Uses = [RETS] in def RTS: F1<(outs), (ins), "rts;", [(BfinRet)]>; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=86851&r1=86850&r2=86851&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Wed Nov 11 12:11:07 2009 @@ -127,7 +127,7 @@ // // FIXME: Provide proper encoding! -let isReturn = 1, isTerminator = 1 in { +let isReturn = 1, isTerminator = 1, isBarrier = 1 in { def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>; } Modified: llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td?rev=86851&r1=86850&r2=86851&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td (original) +++ llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td Wed Nov 11 12:11:07 2009 @@ -277,7 +277,7 @@ // Section A.3 - Synthetic Instructions, p. 85 // special cases of JMPL: -let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in { +let isReturn = 1, isTerminator = 1, hasDelaySlot = 1, isBarrier = 1 in { let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in def RETL: F3_2<2, 0b111000, (outs), (ins), "retl", [(retflag)]>; } Modified: llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td?rev=86851&r1=86850&r2=86851&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td (original) +++ llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td Wed Nov 11 12:11:07 2009 @@ -617,7 +617,7 @@ let mayStore = 1 in defm ENTSP : FU6_LU6_np<"entsp">; -let isReturn = 1, isTerminator = 1, mayLoad = 1 in { +let isReturn = 1, isTerminator = 1, mayLoad = 1, isBarrier = 1 in { defm RETSP : FU6_LU6<"retsp", XCoreRetsp>; } } From gohman at apple.com Wed Nov 11 12:14:02 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:14:02 -0000 Subject: [llvm-commits] [llvm] r86852 - /llvm/trunk/include/llvm/Analysis/CFGPrinter.h Message-ID: <200911111814.nABIE2P7031538@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:14:02 2009 New Revision: 86852 URL: http://llvm.org/viewvc/llvm-project?rev=86852&view=rev Log: Fix a copy+pasto in a comment. Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=86852&r1=86851&r2=86852&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Wed Nov 11 12:14:02 2009 @@ -72,7 +72,7 @@ if (BI->isConditional()) return (I == succ_begin(Node)) ? "T" : "F"; - // Label source of conditional branches with "T" or "F" + // Label source of switch edges with the associated value. if (const SwitchInst *SI = dyn_cast(Node->getTerminator())) { unsigned SuccNo = I.getSuccessorIndex(); From gohman at apple.com Wed Nov 11 12:18:34 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:18:34 -0000 Subject: [llvm-commits] [llvm] r86853 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911111818.nABIIYKj031717@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:18:34 2009 New Revision: 86853 URL: http://llvm.org/viewvc/llvm-project?rev=86853&view=rev Log: Minor code simplification. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86853&r1=86852&r2=86853&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 12:18:34 2009 @@ -875,6 +875,7 @@ /// block. This is never called on the entry block. bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) { bool MadeChange = false; + MachineFunction &MF = *MBB->getParent(); MachineFunction::iterator FallThrough = MBB; ++FallThrough; @@ -887,7 +888,7 @@ // Dead block? Leave for cleanup later. if (MBB->pred_empty()) return MadeChange; - if (FallThrough == MBB->getParent()->end()) { + if (FallThrough == MF.end()) { // TODO: Simplify preds to not branch here if possible! } else { // Rewrite all predecessors of the old block to go to the fallthrough @@ -898,8 +899,7 @@ } // If MBB was the target of a jump table, update jump tables to go to the // fallthrough instead. - MBB->getParent()->getJumpTableInfo()-> - ReplaceMBBInJumpTables(MBB, FallThrough); + MF.getJumpTableInfo()->ReplaceMBBInJumpTables(MBB, FallThrough); MadeChange = true; } return MadeChange; @@ -982,7 +982,7 @@ // last block in the function, we'd just keep swapping the two blocks for // last. Only do the swap if one is clearly better to fall through than // the other. - if (FallThrough == --MBB->getParent()->end() && + if (FallThrough == --MF.end() && !IsBetterFallthrough(PriorTBB, MBB)) DoTransform = false; @@ -1013,7 +1013,7 @@ TII->InsertBranch(PrevBB, MBB, 0, NewPriorCond); // Move this block to the end of the function. - MBB->moveAfter(--MBB->getParent()->end()); + MBB->moveAfter(--MF.end()); MadeChange = true; ++NumBranchOpts; return MadeChange; @@ -1114,8 +1114,7 @@ } // Change any jumptables to go to the new MBB. - MBB->getParent()->getJumpTableInfo()-> - ReplaceMBBInJumpTables(MBB, CurTBB); + MF.getJumpTableInfo()->ReplaceMBBInJumpTables(MBB, CurTBB); if (DidChange) { ++NumBranchOpts; MadeChange = true; @@ -1195,9 +1194,9 @@ // Okay, there is no really great place to put this block. If, however, // the block before this one would be a fall-through if this block were // removed, move this block to the end of the function. - if (FallThrough != MBB->getParent()->end() && + if (FallThrough != MF.end() && PrevBB.isSuccessor(FallThrough)) { - MBB->moveAfter(--MBB->getParent()->end()); + MBB->moveAfter(--MF.end()); MadeChange = true; return MadeChange; } From gohman at apple.com Wed Nov 11 12:23:18 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:23:18 -0000 Subject: [llvm-commits] [llvm] r86854 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911111823.nABINJQB031895@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:23:17 2009 New Revision: 86854 URL: http://llvm.org/viewvc/llvm-project?rev=86854&view=rev Log: Prefix MBB numbers with "BB#" in debug output to make it clear what the numbers mean. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86854&r1=86853&r2=86854&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 12:23:17 2009 @@ -562,7 +562,7 @@ MachineBasicBlock::iterator BBI = SameTails[commonTailIndex].second; MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second; - DEBUG(errs() << "\nSplitting " << MBB->getNumber() << ", size " + DEBUG(errs() << "\nSplitting BB#" << MBB->getNumber() << ", size " << maxCommonTailLength); MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI); @@ -639,11 +639,11 @@ MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second; // MBB is common tail. Adjust all other BB's to jump to this one. // Traversal must be forwards so erases work. - DEBUG(errs() << "\nUsing common tail " << MBB->getNumber() << " for "); + DEBUG(errs() << "\nUsing common tail BB#" << MBB->getNumber() << " for "); for (unsigned int i=0; isecond->getNumber() << ","); + DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() << ", "); // Hack the end off BB i, making it jump to BB commonTailIndex instead. ReplaceTailWithBranchTo(SameTails[i].second, MBB); // BB i is no longer a predecessor of SuccBB; remove it from the worklist. From gohman at apple.com Wed Nov 11 12:31:05 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 10:31:05 -0800 Subject: [llvm-commits] sret-demotion for large struct returns working on x86! In-Reply-To: <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> References: <400d33ea0911081837t48a2447bw7ace6c45c41e8f2@mail.gmail.com> <5CC43A6B-57E4-42A7-B1E6-CCD9875F65D7@apple.com> <400d33ea0911091343w1549702enbbbb0c7b34b75cfa@mail.gmail.com> <400d33ea0911091842i262ebf40t5a39731c6c3de7a7@mail.gmail.com> Message-ID: <5F9E6E75-1386-4FB5-9F71-E167180FB684@apple.com> On Nov 9, 2009, at 6:42 PM, Kenneth Uildriks wrote: > Here's the updated version of the patch: > > 1. Moved the flag and demote register from MachineFunction to > FunctionLoweringInfo > 2. Inverted CantLowerReturn to CanLowerReturn while carrying out #1 > 3. Now passing the return Attributes to getReturnInfo and using its > ZExt and SExt flags properly. > 4. Cleaned up braces. Looks good, thanks! Dan From gohman at apple.com Wed Nov 11 12:38:14 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:38:14 -0000 Subject: [llvm-commits] [llvm] r86855 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911111838.nABIcFjo032372@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:38:14 2009 New Revision: 86855 URL: http://llvm.org/viewvc/llvm-project?rev=86855&view=rev Log: Whitespace cleanups. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86855&r1=86854&r2=86855&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 12:38:14 2009 @@ -40,18 +40,18 @@ STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); -static cl::opt FlagEnableTailMerge("enable-tail-merge", +static cl::opt FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden); // Throttle for huge numbers of predecessors (compile speed problems) static cl::opt -TailMergeThreshold("tail-merge-threshold", +TailMergeThreshold("tail-merge-threshold", cl::desc("Max number of predecessors to consider tail merging"), cl::init(150), cl::Hidden); char BranchFolderPass::ID = 0; -FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { +FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { return new BranchFolderPass(DefaultEnableTailMerge); } @@ -63,7 +63,6 @@ } - BranchFolder::BranchFolder(bool defaultEnableTailMerge) { switch (FlagEnableTailMerge) { case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; @@ -77,12 +76,12 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) { assert(MBB->pred_empty() && "MBB must be dead!"); DEBUG(errs() << "\nRemoving MBB: " << *MBB); - + MachineFunction *MF = MBB->getParent(); // drop all successors. while (!MBB->succ_empty()) MBB->removeSuccessor(MBB->succ_end()-1); - + // If there are any labels in the basic block, unregister them from // MachineModuleInfo. if (MMI && !MBB->empty()) { @@ -93,7 +92,7 @@ MMI->InvalidateLabel(I->getOperand(0).getImm()); } } - + // Remove the block. MF->erase(MBB); } @@ -190,7 +189,7 @@ // Figure out how these jump tables should be merged. std::vector JTMapping; JTMapping.reserve(JTs.size()); - + // We always keep the 0th jump table. JTMapping.push_back(0); @@ -202,7 +201,7 @@ else JTMapping.push_back(JTI->getJumpTableIndex(JTs[i].MBBs)); } - + // If a jump table was merge with another one, walk the function rewriting // references to jump tables to reference the new JT ID's. Keep track of // whether we see a jump table idx, if not, we can delete the JT. @@ -221,7 +220,7 @@ JTIsLive.set(NewIdx); } } - + // Finally, remove dead jump tables. This happens either because the // indirect jump was unreachable (and thus deleted) or because the jump // table was merged with some other one. @@ -245,7 +244,7 @@ unsigned Hash = MI->getOpcode(); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &Op = MI->getOperand(i); - + // Merge in bits from the operand if easy. unsigned OperandHash = 0; switch (Op.getType()) { @@ -267,31 +266,30 @@ break; default: break; } - + Hash += ((OperandHash << 3) | Op.getType()) << (i&31); } return Hash; } /// HashEndOfMBB - Hash the last few instructions in the MBB. For blocks -/// with no successors, we hash two instructions, because cross-jumping -/// only saves code when at least two instructions are removed (since a +/// with no successors, we hash two instructions, because cross-jumping +/// only saves code when at least two instructions are removed (since a /// branch must be inserted). For blocks with a successor, one of the /// two blocks to be tail-merged will end with a branch already, so /// it gains to cross-jump even for one instruction. - static unsigned HashEndOfMBB(const MachineBasicBlock *MBB, unsigned minCommonTailLength) { MachineBasicBlock::const_iterator I = MBB->end(); if (I == MBB->begin()) return 0; // Empty MBB. - + --I; unsigned Hash = HashMachineInstr(I); - + if (I == MBB->begin() || minCommonTailLength == 1) return Hash; // Single instr MBB. - + --I; // Hash in the second-to-last instruction. Hash ^= HashMachineInstr(I) << 2; @@ -307,11 +305,11 @@ MachineBasicBlock::iterator &I2) { I1 = MBB1->end(); I2 = MBB2->end(); - + unsigned TailLen = 0; while (I1 != MBB1->begin() && I2 != MBB2->begin()) { --I1; --I2; - if (!I1->isIdenticalTo(I2) || + if (!I1->isIdenticalTo(I2) || // FIXME: This check is dubious. It's used to get around a problem where // people incorrectly expect inline asm directives to remain in the same // relative order. This is untenable because normal compiler @@ -332,11 +330,11 @@ void BranchFolder::ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst, MachineBasicBlock *NewDest) { MachineBasicBlock *OldBB = OldInst->getParent(); - + // Remove all the old successors of OldBB from the CFG. while (!OldBB->succ_empty()) OldBB->removeSuccessor(OldBB->succ_begin()); - + // Remove all the dead instructions from the end of OldBB. OldBB->erase(OldInst, OldBB->end()); @@ -361,10 +359,10 @@ // Move all the successors of this block to the specified block. NewMBB->transferSuccessors(&CurMBB); - + // Add an edge from CurMBB to NewMBB for the fall-through. CurMBB.addSuccessor(NewMBB); - + // Splice the code over. NewMBB->splice(NewMBB->end(), &CurMBB, BBI1, CurMBB.end()); @@ -404,7 +402,6 @@ // branches temporarily for tail merging). In the case where CurMBB ends // with a conditional branch to the next block, optimize by reversing the // test and conditionally branching to SuccMBB instead. - static void FixTail(MachineBasicBlock* CurMBB, MachineBasicBlock *SuccBB, const TargetInstrInfo *TII) { MachineFunction *MF = CurMBB->getParent(); @@ -476,26 +473,26 @@ } /// ComputeSameTails - Look through all the blocks in MergePotentials that have -/// hash CurHash (guaranteed to match the last element). Build the vector +/// hash CurHash (guaranteed to match the last element). Build the vector /// SameTails of all those that have the (same) largest number of instructions /// in common of any pair of these blocks. SameTails entries contain an -/// iterator into MergePotentials (from which the MachineBasicBlock can be -/// found) and a MachineBasicBlock::iterator into that MBB indicating the +/// iterator into MergePotentials (from which the MachineBasicBlock can be +/// found) and a MachineBasicBlock::iterator into that MBB indicating the /// instruction where the matching code sequence begins. /// Order of elements in SameTails is the reverse of the order in which /// those blocks appear in MergePotentials (where they are not necessarily /// consecutive). -unsigned BranchFolder::ComputeSameTails(unsigned CurHash, +unsigned BranchFolder::ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength) { unsigned maxCommonTailLength = 0U; SameTails.clear(); MachineBasicBlock::iterator TrialBBI1, TrialBBI2; MPIterator HighestMPIter = prior(MergePotentials.end()); for (MPIterator CurMPIter = prior(MergePotentials.end()), - B = MergePotentials.begin(); - CurMPIter!=B && CurMPIter->first==CurHash; + B = MergePotentials.begin(); + CurMPIter!=B && CurMPIter->first == CurHash; --CurMPIter) { - for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) { + for (MPIterator I = prior(CurMPIter); I->first == CurHash ; --I) { unsigned CommonTailLen; if (ProfitableToMerge(CurMPIter->second, I->second, minCommonTailLength, CommonTailLen, TrialBBI1, TrialBBI2)) { @@ -509,7 +506,7 @@ CommonTailLen == maxCommonTailLength) SameTails.push_back(std::make_pair(I, TrialBBI2)); } - if (I==B) + if (I == B) break; } } @@ -518,18 +515,18 @@ /// RemoveBlocksWithHash - Remove all blocks with hash CurHash from /// MergePotentials, restoring branches at ends of blocks as appropriate. -void BranchFolder::RemoveBlocksWithHash(unsigned CurHash, +void BranchFolder::RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB, MachineBasicBlock* PredBB) { MPIterator CurMPIter, B; - for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); - CurMPIter->first==CurHash; + for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); + CurMPIter->first == CurHash; --CurMPIter) { // Put the unconditional branch back, if we need one. MachineBasicBlock *CurMBB = CurMPIter->second; if (SuccBB && CurMBB != PredBB) FixTail(CurMBB, SuccBB, TII); - if (CurMPIter==B) + if (CurMPIter == B) break; } if (CurMPIter->first!=CurHash) @@ -545,15 +542,15 @@ unsigned TimeEstimate = ~0U; for (i=0, commonTailIndex=0; isecond==PredBB) { + if (SameTails[i].first->second == PredBB) { commonTailIndex = i; break; } // Otherwise, make a (fairly bogus) choice based on estimate of // how long it will take the various blocks to execute. - unsigned t = EstimateRuntime(SameTails[i].first->second->begin(), + unsigned t = EstimateRuntime(SameTails[i].first->second->begin(), SameTails[i].second); - if (t<=TimeEstimate) { + if (t <= TimeEstimate) { TimeEstimate = t; commonTailIndex = i; } @@ -568,8 +565,9 @@ MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI); SameTails[commonTailIndex].first->second = newMBB; SameTails[commonTailIndex].second = newMBB->begin(); + // If we split PredBB, newMBB is the new predecessor. - if (PredBB==MBB) + if (PredBB == MBB) PredBB = newMBB; return commonTailIndex; @@ -579,7 +577,7 @@ // successor, or all have no successor) can be tail-merged. If there is a // successor, any blocks in MergePotentials that are not tail-merged and // are not immediately before Succ must have an unconditional branch to -// Succ added (but the predecessor/successor lists need no adjustment). +// Succ added (but the predecessor/successor lists need no adjustment). // The lone predecessor of Succ that falls through into Succ, // if any, is given in PredBB. @@ -591,7 +589,7 @@ // will add a jump. // FIXME: Ask the target to provide the threshold? unsigned minCommonTailLength = (SuccBB ? 1 : 2) + 1; - + DEBUG(errs() << "\nTryMergeBlocks " << MergePotentials.size() << '\n'); // Sort by hash value so that blocks with identical end sequences sort @@ -601,13 +599,13 @@ // Walk through equivalence sets looking for actual exact matches. while (MergePotentials.size() > 1) { unsigned CurHash = MergePotentials.back().first; - + // Build SameTails, identifying the set of blocks with this hash code // and with the maximum number of instructions in common. - unsigned maxCommonTailLength = ComputeSameTails(CurHash, + unsigned maxCommonTailLength = ComputeSameTails(CurHash, minCommonTailLength); - // If we didn't find any pair that has at least minCommonTailLength + // If we didn't find any pair that has at least minCommonTailLength // instructions in common, remove all blocks with this hash code and retry. if (SameTails.empty()) { RemoveBlocksWithHash(CurHash, SuccBB, PredBB); @@ -625,12 +623,12 @@ MachineBasicBlock *MBB = SameTails[i].first->second; if (MBB->begin() == SameTails[i].second && MBB != EntryBB) { commonTailIndex = i; - if (MBB==PredBB) + if (MBB == PredBB) break; } } - if (commonTailIndex==SameTails.size()) { + if (commonTailIndex == SameTails.size()) { // None of the blocks consist entirely of the common tail. // Split a block so that one does. commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength); @@ -641,7 +639,7 @@ // Traversal must be forwards so erases work. DEBUG(errs() << "\nUsing common tail BB#" << MBB->getNumber() << " for "); for (unsigned int i=0; isecond->getNumber() << ", "); // Hack the end off BB i, making it jump to BB commonTailIndex instead. @@ -660,7 +658,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) { if (!EnableTailMerge) return false; - + bool MadeChange = false; // First find blocks with no successors. @@ -669,6 +667,7 @@ if (I->succ_empty()) MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I)); } + // See if we can do any tail merging on those. if (MergePotentials.size() < TailMergeThreshold && MergePotentials.size() >= 2) @@ -679,7 +678,7 @@ // (1) temporarily removing any unconditional branch from the predecessor // to IBB, and // (2) alter conditional branches so they branch to the other block - // not IBB; this may require adding back an unconditional branch to IBB + // not IBB; this may require adding back an unconditional branch to IBB // later, where there wasn't one coming in. E.g. // Bcc IBB // fallthrough to QBB @@ -699,12 +698,12 @@ MachineBasicBlock *IBB = I; MachineBasicBlock *PredBB = prior(I); MergePotentials.clear(); - for (MachineBasicBlock::pred_iterator P = I->pred_begin(), + for (MachineBasicBlock::pred_iterator P = I->pred_begin(), E2 = I->pred_end(); P != E2; ++P) { MachineBasicBlock* PBB = *P; // Skip blocks that loop to themselves, can't tail merge these. - if (PBB==IBB) + if (PBB == IBB) continue; // Visit each predecessor only once. if (!UniquePreds.insert(PBB)) @@ -715,7 +714,7 @@ // Failing case: IBB is the target of a cbr, and // we cannot reverse the branch. SmallVector NewCond(Cond); - if (!Cond.empty() && TBB==IBB) { + if (!Cond.empty() && TBB == IBB) { if (TII->ReverseBranchCondition(NewCond)) continue; // This is the QBB case described above @@ -730,7 +729,7 @@ MachineBasicBlock* PredNextBB = NULL; if (IP!=MF.end()) PredNextBB = IP; - if (TBB==NULL) { + if (TBB == NULL) { if (IBB!=PredNextBB) // fallthrough continue; } else if (FBB) { @@ -749,7 +748,7 @@ TII->RemoveBranch(*PBB); if (!Cond.empty()) // reinsert conditional branch only, for now - TII->InsertBranch(*PBB, (TBB==IBB) ? FBB : TBB, 0, NewCond); + TII->InsertBranch(*PBB, (TBB == IBB) ? FBB : TBB, 0, NewCond); } MergePotentials.push_back(std::make_pair(HashEndOfMBB(PBB, 1U), *P)); } @@ -759,7 +758,7 @@ // Reinsert an unconditional branch if needed. // The 1 below can occur as a result of removing blocks in TryMergeBlocks. PredBB = prior(I); // this may have been changed in TryMergeBlocks - if (MergePotentials.size()==1 && + if (MergePotentials.size() == 1 && MergePotentials.begin()->second != PredBB) FixTail(MergePotentials.begin()->second, I, TII); } @@ -773,14 +772,14 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) { bool MadeChange = false; - + // Make sure blocks are numbered in order MF.RenumberBlocks(); for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; MadeChange |= OptimizeBlock(MBB); - + // If it is dead, remove it. if (MBB->pred_empty()) { RemoveDeadBlock(MBB); @@ -801,7 +800,7 @@ /// bool BranchFolder::CanFallThrough(MachineBasicBlock *CurBB, bool BranchUnAnalyzable, - MachineBasicBlock *TBB, + MachineBasicBlock *TBB, MachineBasicBlock *FBB, const SmallVectorImpl &Cond) { MachineFunction::iterator Fallthrough = CurBB; @@ -809,14 +808,14 @@ // If FallthroughBlock is off the end of the function, it can't fall through. if (Fallthrough == CurBB->getParent()->end()) return false; - + // If FallthroughBlock isn't a successor of CurBB, no fallthrough is possible. if (!CurBB->isSuccessor(Fallthrough)) return false; - + // If we couldn't analyze the branch, assume it could fall through. if (BranchUnAnalyzable) return true; - + // If there is no branch, control always falls through. if (TBB == 0) return true; @@ -825,11 +824,11 @@ if (MachineFunction::iterator(TBB) == Fallthrough || MachineFunction::iterator(FBB) == Fallthrough) return true; - - // If it's an unconditional branch to some block not the fall through, it + + // If it's an unconditional branch to some block not the fall through, it // doesn't fall through. if (Cond.empty()) return false; - + // Otherwise, if it is conditional and has no explicit false block, it falls // through. return FBB == 0; @@ -853,14 +852,14 @@ /// fall-through to MBB1 than to fall through into MBB2. This has to return /// a strict ordering, returning true for both (MBB1,MBB2) and (MBB2,MBB1) will /// result in infinite loops. -static bool IsBetterFallthrough(MachineBasicBlock *MBB1, +static bool IsBetterFallthrough(MachineBasicBlock *MBB1, MachineBasicBlock *MBB2) { // Right now, we use a simple heuristic. If MBB2 ends with a call, and // MBB1 doesn't, we prefer to fall through into MBB1. This allows us to // optimize branches that branch to either a return block or an assert block // into a fallthrough to the return. if (MBB1->empty() || MBB2->empty()) return false; - + // If there is a clear successor ordering we make sure that one block // will fall through to the next if (MBB1->isSuccessor(MBB2)) return true; @@ -879,7 +878,7 @@ MachineFunction::iterator FallThrough = MBB; ++FallThrough; - + // If this block is empty, make everyone use its fall-through, not the block // explicitly. Landing pads should not do this since the landing-pad table // points to this block. Blocks with their addresses taken shouldn't be @@ -887,7 +886,7 @@ if (MBB->empty() && !MBB->isLandingPad() && !MBB->hasAddressTaken()) { // Dead block? Leave for cleanup later. if (MBB->pred_empty()) return MadeChange; - + if (FallThrough == MF.end()) { // TODO: Simplify preds to not branch here if possible! } else { @@ -917,20 +916,20 @@ // If the CFG for the prior block has extra edges, remove them. MadeChange |= PrevBB.CorrectExtraCFGEdges(PriorTBB, PriorFBB, !PriorCond.empty()); - + // If the previous branch is conditional and both conditions go to the same // destination, remove the branch, replacing it with an unconditional one or // a fall-through. if (PriorTBB && PriorTBB == PriorFBB) { TII->RemoveBranch(PrevBB); - PriorCond.clear(); + PriorCond.clear(); if (PriorTBB != MBB) TII->InsertBranch(PrevBB, PriorTBB, 0, PriorCond); MadeChange = true; ++NumBranchOpts; return OptimizeBlock(MBB); } - + // If the previous branch *only* branches to *this* block (conditional or // not) remove the branch. if (PriorTBB == MBB && PriorFBB == 0) { @@ -939,7 +938,7 @@ ++NumBranchOpts; return OptimizeBlock(MBB); } - + // If the prior block branches somewhere else on the condition and here if // the condition is false, remove the uncond second branch. if (PriorFBB == MBB) { @@ -949,7 +948,7 @@ ++NumBranchOpts; return OptimizeBlock(MBB); } - + // If the prior block branches here on true and somewhere else on false, and // if the branch condition is reversible, reverse the branch to create a // fall-through. @@ -963,7 +962,7 @@ return OptimizeBlock(MBB); } } - + // If this block has no successors (e.g. it is a return block or ends with // a call to a no-return function like abort or __cxa_throw) and if the pred // falls through into this block, and if it would otherwise fall through @@ -976,7 +975,7 @@ MachineFunction::iterator(PriorTBB) == FallThrough && !CanFallThrough(MBB)) { bool DoTransform = true; - + // We have to be careful that the succs of PredBB aren't both no-successor // blocks. If neither have successors and if PredBB is the second from // last block in the function, we'd just keep swapping the two blocks for @@ -1000,15 +999,15 @@ if (DoTransform && !MBB->succ_empty() && (!CanFallThrough(PriorTBB) || PriorTBB->empty())) DoTransform = false; - - + + if (DoTransform) { // Reverse the branch so we will fall through on the previous true cond. SmallVector NewPriorCond(PriorCond); if (!TII->ReverseBranchCondition(NewPriorCond)) { DEBUG(errs() << "\nMoving MBB: " << *MBB << "To make fallthrough to: " << *PriorTBB << "\n"); - + TII->RemoveBranch(PrevBB); TII->InsertBranch(PrevBB, MBB, 0, NewPriorCond); @@ -1021,7 +1020,7 @@ } } } - + // Analyze the branch in the current block. MachineBasicBlock *CurTBB = 0, *CurFBB = 0; SmallVector CurCond; @@ -1030,7 +1029,7 @@ // If the CFG for the prior block has extra edges, remove them. MadeChange |= MBB->CorrectExtraCFGEdges(CurTBB, CurFBB, !CurCond.empty()); - // If this is a two-way branch, and the FBB branches to this block, reverse + // If this is a two-way branch, and the FBB branches to this block, reverse // the condition so the single-basic-block loop is faster. Instead of: // Loop: xxx; jcc Out; jmp Loop // we want: @@ -1045,11 +1044,11 @@ return OptimizeBlock(MBB); } } - - + + // If this branch is the only thing in its block, see if we can forward // other blocks across it. - if (CurTBB && CurCond.empty() && CurFBB == 0 && + if (CurTBB && CurCond.empty() && CurFBB == 0 && MBB->begin()->getDesc().isBranch() && CurTBB != MBB && !MBB->hasAddressTaken()) { // This block may contain just an unconditional branch. Because there can @@ -1068,7 +1067,7 @@ !PrevBB.isSuccessor(MBB)) { // If the prior block falls through into us, turn it into an // explicit branch to us to make updates simpler. - if (!PredHasNoFallThrough && PrevBB.isSuccessor(MBB) && + if (!PredHasNoFallThrough && PrevBB.isSuccessor(MBB) && PriorTBB != MBB && PriorFBB != MBB) { if (PriorTBB == 0) { assert(PriorCond.empty() && PriorFBB == 0 && @@ -1104,7 +1103,7 @@ NewCurFBB, NewCurCond, true); if (!NewCurUnAnalyzable && NewCurTBB && NewCurTBB == NewCurFBB) { TII->RemoveBranch(*PMBB); - NewCurCond.clear(); + NewCurCond.clear(); TII->InsertBranch(*PMBB, NewCurTBB, 0, NewCurCond); MadeChange = true; ++NumBranchOpts; @@ -1122,7 +1121,7 @@ } } } - + // Add the branch back if the block is more than just an uncond branch. TII->InsertBranch(*MBB, CurTBB, 0, CurCond); } @@ -1135,7 +1134,7 @@ PriorTBB, PriorFBB, PriorCond)) { // Now we know that there was no fall-through into this block, check to // see if it has a fall-through into its successor. - bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, + bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, CurCond); if (!MBB->isLandingPad()) { @@ -1151,7 +1150,7 @@ && (!CurFallsThru || MBB->getNumber() >= PredBB->getNumber())) { // If the current block doesn't fall through, just move it. // If the current block can fall through and does not end with a - // conditional branch, we need to append an unconditional jump to + // conditional branch, we need to append an unconditional jump to // the (current) next block. To avoid a possible compile-time // infinite loop, move blocks only backward in this case. // Also, if there are already 2 branches here, we cannot add a third; @@ -1170,7 +1169,7 @@ } } } - + if (!CurFallsThru) { // Check all successors to see if we can move this block before it. for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(), @@ -1178,7 +1177,7 @@ // Analyze the branch at the end of the block before the succ. MachineBasicBlock *SuccBB = *SI; MachineFunction::iterator SuccPrev = SuccBB; --SuccPrev; - + // If this block doesn't already fall-through to that successor, and if // the succ doesn't already have a block that can fall through into it, // and if the successor isn't an EH destination, we can arrange for the @@ -1190,7 +1189,7 @@ return OptimizeBlock(MBB); } } - + // Okay, there is no really great place to put this block. If, however, // the block before this one would be a fall-through if this block were // removed, move this block to the end of the function. From gohman at apple.com Wed Nov 11 12:42:28 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 18:42:28 -0000 Subject: [llvm-commits] [llvm] r86856 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911111842.nABIgSTa032532@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 12:42:28 2009 New Revision: 86856 URL: http://llvm.org/viewvc/llvm-project?rev=86856&view=rev Log: Fix indentation level. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86856&r1=86855&r2=86856&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 12:42:28 2009 @@ -753,14 +753,14 @@ MergePotentials.push_back(std::make_pair(HashEndOfMBB(PBB, 1U), *P)); } } - if (MergePotentials.size() >= 2) - MadeChange |= TryMergeBlocks(I, PredBB); - // Reinsert an unconditional branch if needed. - // The 1 below can occur as a result of removing blocks in TryMergeBlocks. - PredBB = prior(I); // this may have been changed in TryMergeBlocks - if (MergePotentials.size() == 1 && - MergePotentials.begin()->second != PredBB) - FixTail(MergePotentials.begin()->second, I, TII); + if (MergePotentials.size() >= 2) + MadeChange |= TryMergeBlocks(I, PredBB); + // Reinsert an unconditional branch if needed. + // The 1 below can occur as a result of removing blocks in TryMergeBlocks. + PredBB = prior(I); // this may have been changed in TryMergeBlocks + if (MergePotentials.size() == 1 && + MergePotentials.begin()->second != PredBB) + FixTail(MergePotentials.begin()->second, I, TII); } } return MadeChange; From grosbach at apple.com Wed Nov 11 13:04:24 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Nov 2009 19:04:24 -0000 Subject: [llvm-commits] [llvm] r86857 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911111904.nABJ4OSE000833@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 11 13:04:24 2009 New Revision: 86857 URL: http://llvm.org/viewvc/llvm-project?rev=86857&view=rev Log: Do jump table adjustment before constant island allocation Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86857&r1=86856&r2=86857&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Wed Nov 11 13:04:24 2009 @@ -294,6 +294,11 @@ // sizes of each block, the location of all the water, and finding all of the // constant pool users. InitialFunctionScan(MF, CPEMIs); + + bool MadeChange = false; + if (isThumb2) + MadeChange |= OptimizeThumb2JumpTables(MF); + CPEMIs.clear(); /// Remove dead constant pool entries. @@ -301,7 +306,6 @@ // Iteratively place constant pool entries and fix up branches until there // is no change. - bool MadeChange = false; unsigned NoCPIters = 0, NoBRIters = 0; while (true) { bool CPChange = false; @@ -1476,7 +1480,6 @@ } MadeChange |= OptimizeThumb2Branches(MF); - MadeChange |= OptimizeThumb2JumpTables(MF); return MadeChange; } @@ -1722,8 +1725,8 @@ JTBB->addSuccessor(NewBB); // Update internal data structures to account for the newly inserted MBB. - // This is almost the same as UpdateForInsertedWaterBlock, except that - // the Water goes after OrigBB, not NewBB. + // Don't mark the new block as having water following it, as we want the + // blocks following the jump table to be as close together as possible. MF.RenumberBlocks(NewBB); // Insert a size into BBSizes to align it properly with the (newly From evan.cheng at apple.com Wed Nov 11 13:05:53 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 19:05:53 -0000 Subject: [llvm-commits] [llvm] r86858 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h Message-ID: <200911111905.nABJ5rXi000907@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 11 13:05:52 2009 New Revision: 86858 URL: http://llvm.org/viewvc/llvm-project?rev=86858&view=rev Log: Add TargetLowering::isLegalICmpImmediate. It tells LSR what immediate can be folded into target icmp instructions. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=86858&r1=86857&r2=86858&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Nov 11 13:05:52 2009 @@ -1514,6 +1514,14 @@ return false; } + /// isLegalICmpImmediate - Return true if the specified immediate is legal + /// icmp immediate, that is the target has icmp instructions which can compare + /// a register against the immediate without having to materialize the + /// immediate into a register. + virtual bool isLegalICmpImmediate(uint64_t Imm) const { + return true; + } + //===--------------------------------------------------------------------===// // Div utility functions // Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=86858&r1=86857&r2=86858&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Nov 11 13:05:52 2009 @@ -3706,6 +3706,18 @@ return true; } +/// isLegalICmpImmediate - Return true if the specified immediate is legal +/// icmp immediate, that is the target has icmp instructions which can compare +/// a register against the immediate without having to materialize the +/// immediate into a register. +bool ARMTargetLowering::isLegalICmpImmediate(uint64_t Imm) const { + if (!Subtarget->isThumb()) + return ARM_AM::getSOImmVal(Imm) != -1; + if (Subtarget->isThumb2()) + return ARM_AM::getT2SOImmVal(Imm) != -1; + return Imm < 256; +} + static bool getARMIndexedAddressParts(SDNode *Ptr, EVT VT, bool isSEXTLoad, SDValue &Base, SDValue &Offset, bool &isInc, Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=86858&r1=86857&r2=86858&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Wed Nov 11 13:05:52 2009 @@ -180,6 +180,12 @@ virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const; bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const; + /// isLegalICmpImmediate - Return true if the specified immediate is legal + /// icmp immediate, that is the target has icmp instructions which can compare + /// a register against the immediate without having to materialize the + /// immediate into a register. + virtual bool isLegalICmpImmediate(uint64_t Imm) const; + /// getPreIndexedAddressParts - returns true by value, base pointer and /// offset pointer and addressing mode by reference if the node's address /// can be legally represented as pre-indexed load / store address. From dpatel at apple.com Wed Nov 11 13:06:06 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 19:06:06 -0000 Subject: [llvm-commits] [llvm] r86859 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200911111906.nABJ66Dt000926@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 13:06:06 2009 New Revision: 86859 URL: http://llvm.org/viewvc/llvm-project?rev=86859&view=rev Log: Add SetDebugLocation() variant to add debug info location to an instruction. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=86859&r1=86858&r2=86859&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Nov 11 13:06:06 2009 @@ -151,6 +151,15 @@ Context.getMetadata().addMD(MDKind, CurDbgLocation, I); } + /// SetDebugLocation - Set location information for the given instruction. + void SetDebugLocation(Instruction *I, MDNode *Loc) { + if (MDKind == 0) + MDKind = Context.getMetadata().getMDKind("dbg"); + if (MDKind == 0) + MDKind = Context.getMetadata().registerMDKind("dbg"); + Context.getMetadata().addMD(MDKind, Loc, I); + } + /// Insert - Insert and return the specified instruction. template InstTy *Insert(InstTy *I, const Twine &Name = "") const { From dpatel at apple.com Wed Nov 11 13:07:28 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 19:07:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86860 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200911111907.nABJ7SDl000985@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 13:07:28 2009 New Revision: 86860 URL: http://llvm.org/viewvc/llvm-project?rev=86860&view=rev Log: Create new location to attach with llvm.dbg.declare. This location is only used to find the context of the variable by the code generator. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=86860&r1=86859&r2=86860&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Nov 11 13:07:28 2009 @@ -333,7 +333,15 @@ // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); - Builder.SetDebugLocation(Call); + +#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN + llvm::DIDescriptor DR = RegionStack.back(); + llvm::DIScope DS = llvm::DIScope(DR.getNode()); + llvm::DILocation DO(NULL); + llvm::DILocation DL = + DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); + Builder.SetDebugLocation(Call, DL.getNode()); +#endif } From dpatel at apple.com Wed Nov 11 13:08:42 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 19:08:42 -0000 Subject: [llvm-commits] [llvm] r86861 - /llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Message-ID: <200911111908.nABJ8g8s001037@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 13:08:42 2009 New Revision: 86861 URL: http://llvm.org/viewvc/llvm-project?rev=86861&view=rev Log: Reenable StackTracke.cpp test. Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=86861&r1=86860&r2=86861&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Wed Nov 11 13:08:42 2009 @@ -12,7 +12,7 @@ // Only works on ppc (but not apple-darwin9), x86 and x86_64. Should // generalize? -// XFAIL: * +// XFAIL: alpha,arm,powerpc-apple-darwin9 #include From stoklund at 2pi.dk Wed Nov 11 13:31:31 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 11 Nov 2009 19:31:31 -0000 Subject: [llvm-commits] [llvm] r86867 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp lib/CodeGen/PHIElimination.cpp lib/CodeGen/PHIElimination.h Message-ID: <200911111931.nABJVVao001949@zion.cs.uiuc.edu> Author: stoklund Date: Wed Nov 11 13:31:31 2009 New Revision: 86867 URL: http://llvm.org/viewvc/llvm-project?rev=86867&view=rev Log: Fix liveness calculation when splitting critical edges during PHI elimination. - Edges are split before any phis are eliminated, so the code is SSA. - Create a proper IR BasicBlock for the split edges. - LiveVariables::addNewBlock now has same syntax as MachineDominatorTree::addNewBlock. Algorithm calculates predecessor live-out set rather than successor live-in set. This feature still causes some miscompilations. Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h llvm/trunk/lib/CodeGen/LiveVariables.cpp llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=86867&r1=86866&r2=86867&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Wed Nov 11 13:31:31 2009 @@ -267,9 +267,11 @@ void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MachineInstr *MI); - /// addNewBlock - Add a new basic block A as an empty predecessor of B. All - /// variables that are live into B will be marked as passing live through A. - void addNewBlock(MachineBasicBlock *A, MachineBasicBlock *B); + /// addNewBlock - Add a new basic block BB as an empty succcessor to + /// DomBB. All variables that are live out of DomBB will be marked as passing + /// live through BB. This method assumes that the machine code is still in SSA + /// form. + void addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB); }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=86867&r1=86866&r2=86867&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Wed Nov 11 13:31:31 2009 @@ -650,34 +650,35 @@ .push_back(BBI->getOperand(i).getReg()); } -void LiveVariables::addNewBlock(MachineBasicBlock *A, MachineBasicBlock *B) { - unsigned NumA = A->getNumber(); - unsigned NumB = B->getNumber(); +/// addNewBlock - Add a new basic block BB as an empty succcessor to DomBB. All +/// variables that are live out of DomBB will be marked as passing live through +/// BB. +void LiveVariables::addNewBlock(MachineBasicBlock *BB, + MachineBasicBlock *DomBB) { + const unsigned NumNew = BB->getNumber(); + const unsigned NumDom = DomBB->getNumber(); // Update info for all live variables - for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) { - VarInfo &VI = VirtRegInfo[i]; - - // Anything live through B is also live through A. - if (VI.AliveBlocks.test(NumB)) { - VI.AliveBlocks.set(NumA); + for (unsigned Reg = TargetRegisterInfo::FirstVirtualRegister, + E = MRI->getLastVirtReg()+1; Reg != E; ++Reg) { + VarInfo &VI = getVarInfo(Reg); + + // Anything live through DomBB is also live through BB. + if (VI.AliveBlocks.test(NumDom)) { + VI.AliveBlocks.set(NumNew); continue; } - // If we're not killed in B, we are not live in - if (!VI.findKill(B)) + // Variables not defined in DomBB cannot be live out. + const MachineInstr *Def = MRI->getVRegDef(Reg); + if (!Def || Def->getParent() != DomBB) continue; - unsigned Reg = i+TargetRegisterInfo::FirstVirtualRegister; + // Killed by DomBB? + if (VI.findKill(DomBB)) + continue; - // Find a def outside B - for (MachineRegisterInfo::def_iterator di = MRI->def_begin(Reg), - de=MRI->def_end(); di != de; ++di) { - if (di->getParent() != B) { - // Reg was defined outside B and killed in B - it must be live in. - VI.AliveBlocks.set(NumA); - break; - } - } + // This register is defined in DomBB and live out + VI.AliveBlocks.set(NumNew); } } Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=86867&r1=86866&r2=86867&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Wed Nov 11 13:31:31 2009 @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Function.h" #include "llvm/Target/TargetMachine.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" @@ -65,10 +66,17 @@ PHIDefs.clear(); PHIKills.clear(); - analyzePHINodes(Fn); bool Changed = false; + // Split critical edges to help the coalescer + if (SplitEdges) + for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) + Changed |= SplitPHIEdges(Fn, *I); + + // Populate VRegPHIUseCount + analyzePHINodes(Fn); + // Eliminate PHI instructions by inserting copies into predecessor blocks. for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) Changed |= EliminatePHINodes(Fn, *I); @@ -87,7 +95,6 @@ return Changed; } - /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions in /// predecessor basic blocks. /// @@ -96,9 +103,6 @@ if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI) return false; // Quick exit for basic blocks without PHIs. - if (SplitEdges) - SplitPHIEdges(MF, MBB); - // Get an iterator to the first instruction after the last PHI node (this may // also be the end of the basic block). MachineBasicBlock::iterator AfterPHIsIt = SkipPHIsAndLabels(MBB, MBB.begin()); @@ -293,7 +297,7 @@ // Okay, if we now know that the value is not live out of the block, we can // add a kill marker in this block saying that it kills the incoming value! // When SplitEdges is enabled, the value is never live out. - if (!ValueIsUsed && (SplitEdges || !isLiveOut(SrcReg, opBlock, *LV))) { + if (!ValueIsUsed && !isLiveOut(SrcReg, opBlock, *LV)) { // In our final twist, we have to decide which instruction kills the // register. In most cases this is the copy, however, the first // terminator instruction at the end of the block may also use the value. @@ -345,8 +349,10 @@ BBI->getOperand(i).getReg())]; } -void llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF, +bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB) { + if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI) + return false; // Quick exit for basic blocks without PHIs. LiveVariables &LV = getAnalysis(); for (MachineBasicBlock::const_iterator BBI = MBB.begin(), BBE = MBB.end(); BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) { @@ -354,29 +360,29 @@ unsigned Reg = BBI->getOperand(i).getReg(); MachineBasicBlock *PreMBB = BBI->getOperand(i+1).getMBB(); // We break edges when registers are live out from the predecessor block - // (not considering PHI nodes). - if (isLiveOut(Reg, *PreMBB, LV)) + // (not considering PHI nodes). If the register is live in to this block + // anyway, we would gain nothing from splitting. + if (isLiveOut(Reg, *PreMBB, LV) && !isLiveIn(Reg, MBB, LV)) SplitCriticalEdge(PreMBB, &MBB); } } + return true; } bool llvm::PHIElimination::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, LiveVariables &LV) { - LiveVariables::VarInfo &InRegVI = LV.getVarInfo(Reg); + LiveVariables::VarInfo &VI = LV.getVarInfo(Reg); // Loop over all of the successors of the basic block, checking to see if // the value is either live in the block, or if it is killed in the block. std::vector OpSuccBlocks; - - // Otherwise, scan successors, including the BB the PHI node lives in. for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(), E = MBB.succ_end(); SI != E; ++SI) { MachineBasicBlock *SuccMBB = *SI; // Is it alive in this successor? unsigned SuccIdx = SuccMBB->getNumber(); - if (InRegVI.AliveBlocks.test(SuccIdx)) + if (VI.AliveBlocks.test(SuccIdx)) return true; OpSuccBlocks.push_back(SuccMBB); } @@ -386,36 +392,56 @@ switch (OpSuccBlocks.size()) { case 1: { MachineBasicBlock *SuccMBB = OpSuccBlocks[0]; - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (InRegVI.Kills[i]->getParent() == SuccMBB) + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) + if (VI.Kills[i]->getParent() == SuccMBB) return true; break; } case 2: { MachineBasicBlock *SuccMBB1 = OpSuccBlocks[0], *SuccMBB2 = OpSuccBlocks[1]; - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (InRegVI.Kills[i]->getParent() == SuccMBB1 || - InRegVI.Kills[i]->getParent() == SuccMBB2) + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) + if (VI.Kills[i]->getParent() == SuccMBB1 || + VI.Kills[i]->getParent() == SuccMBB2) return true; break; } default: std::sort(OpSuccBlocks.begin(), OpSuccBlocks.end()); - for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) if (std::binary_search(OpSuccBlocks.begin(), OpSuccBlocks.end(), - InRegVI.Kills[i]->getParent())) + VI.Kills[i]->getParent())) return true; } return false; } +bool llvm::PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock &MBB, + LiveVariables &LV) { + LiveVariables::VarInfo &VI = LV.getVarInfo(Reg); + + return VI.AliveBlocks.test(MBB.getNumber()) || VI.findKill(&MBB); +} + MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, MachineBasicBlock *B) { assert(A && B && "Missing MBB end point"); ++NumSplits; + BasicBlock *ABB = const_cast(A->getBasicBlock()); + BasicBlock *BBB = const_cast(B->getBasicBlock()); + assert(ABB && BBB && "End points must have a basic block"); + BasicBlock *BB = BasicBlock::Create(BBB->getContext(), + ABB->getName() + "." + BBB->getName() + + "_phi_edge"); + Function *F = ABB->getParent(); + F->getBasicBlockList().insert(F->end(), BB); + + BranchInst::Create(BBB, BB); + // We could do more here to produce correct IR, compare + // llvm::SplitCriticalEdge + MachineFunction *MF = A->getParent(); - MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(B->getBasicBlock()); + MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(BB); MF->push_back(NMBB); const unsigned NewNum = NMBB->getNumber(); DEBUG(errs() << "PHIElimination splitting critical edge:" @@ -430,21 +456,14 @@ SmallVector Cond; MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); - LiveVariables *LV = getAnalysisIfAvailable(); - if (LV) - LV->addNewBlock(NMBB, B); + if (LiveVariables *LV = getAnalysisIfAvailable()) + LV->addNewBlock(NMBB, A); // Fix PHI nodes in B so they refer to NMBB instead of A for (MachineBasicBlock::iterator i = B->begin(), e = B->end(); i != e && i->getOpcode() == TargetInstrInfo::PHI; ++i) for (unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2) - if (i->getOperand(ni+1).getMBB() == A) { + if (i->getOperand(ni+1).getMBB() == A) i->getOperand(ni+1).setMBB(NMBB); - // Mark PHI sources as passing live through NMBB - if (LV) - LV->getVarInfo(i->getOperand(ni).getReg()).AliveBlocks.set(NewNum); - } return NMBB; } - - Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=86867&r1=86866&r2=86867&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Wed Nov 11 13:31:31 2009 @@ -90,7 +90,7 @@ void analyzePHINodes(const MachineFunction& Fn); /// Split critical edges where necessary for good coalescer performance. - void SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB); + bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB); /// isLiveOut - Determine if Reg is live out from MBB, when not /// considering PHI nodes. This means that Reg is either killed by @@ -98,6 +98,12 @@ bool isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, LiveVariables &LV); + /// isLiveIn - Determine if Reg is live in to MBB, not considering PHI + /// source registers. This means that Reg is either killed by MBB or passes + /// through it. + bool isLiveIn(unsigned Reg, const MachineBasicBlock &MBB, + LiveVariables &LV); + /// SplitCriticalEdge - Split a critical edge from A to B by /// inserting a new MBB. Update branches in A and PHI instructions /// in B. Return the new block. From gohman at apple.com Wed Nov 11 13:49:00 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 19:49:00 -0000 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll Message-ID: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 13:48:59 2009 New Revision: 86871 URL: http://llvm.org/viewvc/llvm-project?rev=86871&view=rev Log: Add support for tail duplication to BranchFolding, and extend tail merging support to handle more cases. - Recognize several cases where tail merging is beneficial even when the tail size is smaller than the generic threshold. - Make use of MachineInstrDesc::isBarrier to help detect non-fallthrough blocks. - Check for and avoid disrupting fall-through edges in more cases. Added: llvm/trunk/test/CodeGen/X86/tail-opts.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt3.ll llvm/trunk/test/CodeGen/X86/loop-blocks.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86871&r1=86870&r2=86871&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 13:48:59 2009 @@ -32,6 +32,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -48,10 +49,16 @@ cl::desc("Max number of predecessors to consider tail merging"), cl::init(150), cl::Hidden); +// Heuristic for tail merging (and, inversely, tail duplication). +// TODO: This should be replaced with a target query. +static cl::opt +TailMergeSize("tail-merge-size", + cl::desc("Min number of instructions to consider tail merging"), + cl::init(3), cl::Hidden); char BranchFolderPass::ID = 0; -FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { +Pass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { return new BranchFolderPass(DefaultEnableTailMerge); } @@ -442,6 +449,25 @@ } } +/// CountTerminators - Count the number of terminators in the given +/// block and set I to the position of the first non-terminator, if there +/// is one, or MBB->end() otherwise. +static unsigned CountTerminators(MachineBasicBlock *MBB, + MachineBasicBlock::iterator &I) { + I = MBB->end(); + unsigned NumTerms = 0; + for (;;) { + if (I == MBB->begin()) { + I = MBB->end(); + break; + } + --I; + if (!I->getDesc().isTerminator()) break; + ++NumTerms; + } + return NumTerms; +} + /// ProfitableToMerge - Check if two machine basic blocks have a common tail /// and decide if it would be profitable to merge those tails. Return the /// length of the common tail and iterators to the first common instruction @@ -451,16 +477,35 @@ unsigned minCommonTailLength, unsigned &CommonTailLen, MachineBasicBlock::iterator &I1, - MachineBasicBlock::iterator &I2) { + MachineBasicBlock::iterator &I2, + MachineBasicBlock *SuccBB, + MachineBasicBlock *PredBB) { CommonTailLen = ComputeCommonTailLength(MBB1, MBB2, I1, I2); MachineFunction *MF = MBB1->getParent(); - if (CommonTailLen >= minCommonTailLength) - return true; - if (CommonTailLen == 0) return false; + // It's almost always profitable to merge any number of non-terminator + // instructions with the block that falls through into the common successor. + if (MBB1 == PredBB || MBB2 == PredBB) { + MachineBasicBlock::iterator I; + unsigned NumTerms = CountTerminators(MBB1 == PredBB ? MBB2 : MBB1, I); + if (CommonTailLen > NumTerms) + return true; + } + + // If both blocks have an unconditional branch temporarily stripped out, + // treat that as an additional common instruction. + if (MBB1 != PredBB && MBB2 != PredBB && + !MBB1->back().getDesc().isBarrier() && + !MBB2->back().getDesc().isBarrier()) + --minCommonTailLength; + + // Check if the common tail is long enough to be worthwhile. + if (CommonTailLen >= minCommonTailLength) + return true; + // If we are optimizing for code size, 1 instruction in common is enough if // we don't have to split a block. At worst we will be replacing a // fallthrough into the common tail with a branch, which at worst breaks @@ -483,7 +528,9 @@ /// those blocks appear in MergePotentials (where they are not necessarily /// consecutive). unsigned BranchFolder::ComputeSameTails(unsigned CurHash, - unsigned minCommonTailLength) { + unsigned minCommonTailLength, + MachineBasicBlock *SuccBB, + MachineBasicBlock *PredBB) { unsigned maxCommonTailLength = 0U; SameTails.clear(); MachineBasicBlock::iterator TrialBBI1, TrialBBI2; @@ -495,7 +542,8 @@ for (MPIterator I = prior(CurMPIter); I->first == CurHash ; --I) { unsigned CommonTailLen; if (ProfitableToMerge(CurMPIter->second, I->second, minCommonTailLength, - CommonTailLen, TrialBBI1, TrialBBI2)) { + CommonTailLen, TrialBBI1, TrialBBI2, + SuccBB, PredBB)) { if (CommonTailLen > maxCommonTailLength) { SameTails.clear(); maxCommonTailLength = CommonTailLen; @@ -581,16 +629,62 @@ // The lone predecessor of Succ that falls through into Succ, // if any, is given in PredBB. -bool BranchFolder::TryMergeBlocks(MachineBasicBlock *SuccBB, - MachineBasicBlock* PredBB) { +bool BranchFolder::TryTailMergeBlocks(MachineBasicBlock *SuccBB, + MachineBasicBlock* PredBB) { bool MadeChange = false; - // It doesn't make sense to save a single instruction since tail merging - // will add a jump. - // FIXME: Ask the target to provide the threshold? - unsigned minCommonTailLength = (SuccBB ? 1 : 2) + 1; + // Except for the special cases below, tail-merge if there are at least + // this many instructions in common. + unsigned minCommonTailLength = TailMergeSize; + + // If there's a successor block, there are some cases which don't require + // new branching and as such are very likely to be profitable. + if (SuccBB) { + if (SuccBB->pred_size() == MergePotentials.size() && + !MergePotentials[0].second->empty()) { + // If all the predecessors have at least one tail instruction in common, + // merging is very likely to be a win since it won't require an increase + // in static branches, and it will decrease the static instruction count. + bool AllPredsMatch = true; + MachineBasicBlock::iterator FirstNonTerm; + unsigned MinNumTerms = CountTerminators(MergePotentials[0].second, + FirstNonTerm); + if (FirstNonTerm != MergePotentials[0].second->end()) { + for (unsigned i = 1, e = MergePotentials.size(); i != e; ++i) { + MachineBasicBlock::iterator OtherFirstNonTerm; + unsigned NumTerms = CountTerminators(MergePotentials[0].second, + OtherFirstNonTerm); + if (NumTerms < MinNumTerms) + MinNumTerms = NumTerms; + if (OtherFirstNonTerm == MergePotentials[i].second->end() || + OtherFirstNonTerm->isIdenticalTo(FirstNonTerm)) { + AllPredsMatch = false; + break; + } + } + + // If they all have an instruction in common, do any amount of merging. + if (AllPredsMatch) + minCommonTailLength = MinNumTerms + 1; + } + } + } - DEBUG(errs() << "\nTryMergeBlocks " << MergePotentials.size() << '\n'); + DEBUG(errs() << "\nTryTailMergeBlocks: "; + for (unsigned i = 0, e = MergePotentials.size(); i != e; ++i) + errs() << "BB#" << MergePotentials[i].second->getNumber() + << (i == e-1 ? "" : ", "); + errs() << "\n"; + if (SuccBB) { + errs() << " with successor BB#" << SuccBB->getNumber() << '\n'; + if (PredBB) + errs() << " which has fall-through from BB#" + << PredBB->getNumber() << "\n"; + } + errs() << "Looking for common tails of at least " + << minCommonTailLength << " instruction" + << (minCommonTailLength == 1 ? "" : "s") << '\n'; + ); // Sort by hash value so that blocks with identical end sequences sort // together. @@ -603,7 +697,8 @@ // Build SameTails, identifying the set of blocks with this hash code // and with the maximum number of instructions in common. unsigned maxCommonTailLength = ComputeSameTails(CurHash, - minCommonTailLength); + minCommonTailLength, + SuccBB, PredBB); // If we didn't find any pair that has at least minCommonTailLength // instructions in common, remove all blocks with this hash code and retry. @@ -621,27 +716,35 @@ unsigned int commonTailIndex, i; for (commonTailIndex=SameTails.size(), i=0; isecond; - if (MBB->begin() == SameTails[i].second && MBB != EntryBB) { + if (MBB == EntryBB) + continue; + if (MBB == PredBB) { commonTailIndex = i; - if (MBB == PredBB) - break; + break; } + if (MBB->begin() == SameTails[i].second) + commonTailIndex = i; } - if (commonTailIndex == SameTails.size()) { + if (commonTailIndex == SameTails.size() || + (SameTails[commonTailIndex].first->second == PredBB && + SameTails[commonTailIndex].first->second->begin() != + SameTails[i].second)) { // None of the blocks consist entirely of the common tail. // Split a block so that one does. - commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength); + commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength); } MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second; // MBB is common tail. Adjust all other BB's to jump to this one. // Traversal must be forwards so erases work. - DEBUG(errs() << "\nUsing common tail BB#" << MBB->getNumber() << " for "); - for (unsigned int i=0; igetNumber() + << " for "); + for (unsigned int i=0, e = SameTails.size(); i != e; ++i) { if (commonTailIndex == i) continue; - DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() << ", "); + DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() + << (i == e-1 ? "" : ", ")); // Hack the end off BB i, making it jump to BB commonTailIndex instead. ReplaceTailWithBranchTo(SameTails[i].second, MBB); // BB i is no longer a predecessor of SuccBB; remove it from the worklist. @@ -671,7 +774,7 @@ // See if we can do any tail merging on those. if (MergePotentials.size() < TailMergeThreshold && MergePotentials.size() >= 2) - MadeChange |= TryMergeBlocks(NULL, NULL); + MadeChange |= TryTailMergeBlocks(NULL, NULL); // Look at blocks (IBB) with multiple predecessors (PBB). // We change each predecessor to a canonical form, by @@ -692,7 +795,8 @@ // a compile-time infinite loop repeatedly doing and undoing the same // transformations.) - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { + for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); + I != E; ++I) { if (I->pred_size() >= 2 && I->pred_size() < TailMergeThreshold) { SmallPtrSet UniquePreds; MachineBasicBlock *IBB = I; @@ -754,13 +858,13 @@ } } if (MergePotentials.size() >= 2) - MadeChange |= TryMergeBlocks(I, PredBB); + MadeChange |= TryTailMergeBlocks(IBB, PredBB); // Reinsert an unconditional branch if needed. - // The 1 below can occur as a result of removing blocks in TryMergeBlocks. - PredBB = prior(I); // this may have been changed in TryMergeBlocks + // The 1 below can occur as a result of removing blocks in TryTailMergeBlocks. + PredBB = prior(I); // this may have been changed in TryTailMergeBlocks if (MergePotentials.size() == 1 && MergePotentials.begin()->second != PredBB) - FixTail(MergePotentials.begin()->second, I, TII); + FixTail(MergePotentials.begin()->second, IBB, TII); } } return MadeChange; @@ -813,9 +917,17 @@ if (!CurBB->isSuccessor(Fallthrough)) return false; - // If we couldn't analyze the branch, assume it could fall through. - if (BranchUnAnalyzable) return true; - + // If we couldn't analyze the branch, examine the last instruction. + // If the block doesn't end in a known control barrier, assume fallthrough + // is possible. The isPredicable check is needed because this code can be + // called during IfConversion, where an instruction which is normally a + // Barrier is predicated and thus no longer an actual control barrier. This + // is over-conservative though, because if an instruction isn't actually + // predicated we could still treat it like a barrier. + if (BranchUnAnalyzable) + return CurBB->empty() || !CurBB->back().getDesc().isBarrier() || + CurBB->back().getDesc().isPredicable(); + // If there is no branch, control always falls through. if (TBB == 0) return true; @@ -870,11 +982,108 @@ return MBB2I->getDesc().isCall() && !MBB1I->getDesc().isCall(); } +/// TailDuplicate - MBB unconditionally branches to SuccBB. If it is profitable, +/// duplicate SuccBB's contents in MBB to eliminate the branch. +bool BranchFolder::TailDuplicate(MachineBasicBlock *TailBB, + bool PrevFallsThrough, + MachineFunction &MF) { + // Don't try to tail-duplicate single-block loops. + if (TailBB->isSuccessor(TailBB)) + return false; + + // Don't tail-duplicate a block which will soon be folded into its successor. + if (TailBB->succ_size() == 1 && + TailBB->succ_begin()[0]->pred_size() == 1) + return false; + + // Duplicate up to one less that the tail-merge threshold, so that we don't + // get into an infinite loop between duplicating and merging. When optimizing + // for size, duplicate only one, because one branch instruction can be + // eliminated to compensate for the duplication. + unsigned MaxDuplicateCount = + MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize) ? + 1 : (TailMergeSize - 1); + + // Check the instructions in the block to determine whether tail-duplication + // is invalid or unlikely to be unprofitable. + unsigned i = 0; + bool HasCall = false; + for (MachineBasicBlock::iterator I = TailBB->begin(); + I != TailBB->end(); ++I, ++i) { + // Non-duplicable things shouldn't be tail-duplicated. + if (I->getDesc().isNotDuplicable()) return false; + // Don't duplicate more than the threshold. + if (i == MaxDuplicateCount) return false; + // Remember if we saw a call. + if (I->getDesc().isCall()) HasCall = true; + } + // Heuristically, don't tail-duplicate calls if it would expand code size, + // as it's less likely to be worth the extra cost. + if (i > 1 && HasCall) + return false; + + // Iterate through all the unique predecessors and tail-duplicate this + // block into them, if possible. Copying the list ahead of time also + // avoids trouble with the predecessor list reallocating. + bool Changed = false; + SmallSetVector Preds(TailBB->pred_begin(), + TailBB->pred_end()); + for (SmallSetVector::iterator PI = Preds.begin(), + PE = Preds.end(); PI != PE; ++PI) { + MachineBasicBlock *PredBB = *PI; + + assert(TailBB != PredBB && + "Single-block loop should have been rejected earlier!"); + if (PredBB->succ_size() > 1) continue; + + MachineBasicBlock *PredTBB, *PredFBB; + SmallVector PredCond; + if (TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true)) + continue; + if (!PredCond.empty()) + continue; + // EH edges are ignored by AnalyzeBranch. + if (PredBB->succ_size() != 1) + continue; + // Don't duplicate into a fall-through predecessor unless its the + // only predecessor. + if (&*next(MachineFunction::iterator(PredBB)) == TailBB && + PrevFallsThrough && + TailBB->pred_size() != 1) + continue; + + DEBUG(errs() << "\nTail-duplicating into PredBB: " << *PredBB + << "From Succ: " << *TailBB); + + // Remove PredBB's unconditional branch. + TII->RemoveBranch(*PredBB); + // Clone the contents of TailBB into PredBB. + for (MachineBasicBlock::iterator I = TailBB->begin(), E = TailBB->end(); + I != E; ++I) { + MachineInstr *NewMI = MF.CloneMachineInstr(I); + PredBB->insert(PredBB->end(), NewMI); + } + + // Update the CFG. + PredBB->removeSuccessor(PredBB->succ_begin()); + assert(PredBB->succ_empty() && + "TailDuplicate called on block with multiple successors!"); + for (MachineBasicBlock::succ_iterator I = TailBB->succ_begin(), + E = TailBB->succ_end(); I != E; ++I) + PredBB->addSuccessor(*I); + + Changed = true; + } + + return Changed; +} + /// OptimizeBlock - Analyze and optimize control flow related to the specified /// block. This is never called on the entry block. bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) { bool MadeChange = false; MachineFunction &MF = *MBB->getParent(); +ReoptimizeBlock: MachineFunction::iterator FallThrough = MBB; ++FallThrough; @@ -927,16 +1136,36 @@ TII->InsertBranch(PrevBB, PriorTBB, 0, PriorCond); MadeChange = true; ++NumBranchOpts; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } + // If the previous block unconditionally falls through to this block and + // this block has no other predecessors, move the contents of this block + // into the prior block. This doesn't usually happen when SimplifyCFG + // has been used, but it can happen tail duplication eliminates all the + // non-branch predecessors of a block leaving only the fall-through edge. + // This has to check PrevBB->succ_size() because EH edges are ignored by + // AnalyzeBranch. + if (PriorCond.empty() && !PriorTBB && MBB->pred_size() == 1 && + PrevBB.succ_size() == 1 && + !MBB->hasAddressTaken()) { + DEBUG(errs() << "\nMerging into block: " << PrevBB + << "From MBB: " << *MBB); + PrevBB.splice(PrevBB.end(), MBB, MBB->begin(), MBB->end()); + PrevBB.removeSuccessor(PrevBB.succ_begin());; + assert(PrevBB.succ_empty()); + PrevBB.transferSuccessors(MBB); + MadeChange = true; + return MadeChange; + } + // If the previous branch *only* branches to *this* block (conditional or // not) remove the branch. if (PriorTBB == MBB && PriorFBB == 0) { TII->RemoveBranch(PrevBB); MadeChange = true; ++NumBranchOpts; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } // If the prior block branches somewhere else on the condition and here if @@ -946,7 +1175,7 @@ TII->InsertBranch(PrevBB, PriorTBB, 0, PriorCond); MadeChange = true; ++NumBranchOpts; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } // If the prior block branches here on true and somewhere else on false, and @@ -959,7 +1188,7 @@ TII->InsertBranch(PrevBB, PriorFBB, 0, NewPriorCond); MadeChange = true; ++NumBranchOpts; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } } @@ -1041,7 +1270,7 @@ TII->InsertBranch(*MBB, CurFBB, CurTBB, NewCond); MadeChange = true; ++NumBranchOpts; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } } @@ -1107,7 +1336,7 @@ TII->InsertBranch(*PMBB, NewCurTBB, 0, NewCurCond); MadeChange = true; ++NumBranchOpts; - PMBB->CorrectExtraCFGEdges(NewCurTBB, NewCurFBB, false); + PMBB->CorrectExtraCFGEdges(NewCurTBB, 0, false); } } } @@ -1127,16 +1356,26 @@ } } + // Now we know that there was no fall-through into this block, check to + // see if it has a fall-through into its successor. + bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, + CurCond); + bool PrevFallsThru = CanFallThrough(&PrevBB, PriorUnAnalyzable, + PriorTBB, PriorFBB, PriorCond); + + // If this block is small, unconditionally branched to, and does not + // fall through, tail-duplicate its instructions into its predecessors + // to eliminate a (dynamic) branch. + if (!CurFallsThru) + if (TailDuplicate(MBB, PrevFallsThru, MF)) { + MadeChange = true; + return MadeChange; + } + // If the prior block doesn't fall through into this block, and if this // block doesn't fall through into some other block, see if we can find a // place to move this block where a fall-through will happen. - if (!CanFallThrough(&PrevBB, PriorUnAnalyzable, - PriorTBB, PriorFBB, PriorCond)) { - // Now we know that there was no fall-through into this block, check to - // see if it has a fall-through into its successor. - bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, - CurCond); - + if (!PrevFallsThru) { if (!MBB->isLandingPad()) { // Check all the predecessors of this block. If one of them has no fall // throughs, move this block right after it. @@ -1145,7 +1384,10 @@ // Analyze the branch at the end of the pred. MachineBasicBlock *PredBB = *PI; MachineFunction::iterator PredFallthrough = PredBB; ++PredFallthrough; - if (PredBB != MBB && !CanFallThrough(PredBB) + MachineBasicBlock *PredTBB, *PredFBB; + SmallVector PredCond; + if (PredBB != MBB && !CanFallThrough(PredBB) && + !TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true) && (!CurFallsThru || !CurTBB || !CurFBB) && (!CurFallsThru || MBB->getNumber() >= PredBB->getNumber())) { // If the current block doesn't fall through, just move it. @@ -1165,7 +1407,7 @@ } MBB->moveAfter(PredBB); MadeChange = true; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } } } @@ -1182,18 +1424,22 @@ // the succ doesn't already have a block that can fall through into it, // and if the successor isn't an EH destination, we can arrange for the // fallthrough to happen. - if (SuccBB != MBB && !CanFallThrough(SuccPrev) && + if (SuccBB != MBB && &*SuccPrev != MBB && + !CanFallThrough(SuccPrev) && !CurUnAnalyzable && !SuccBB->isLandingPad()) { MBB->moveBefore(SuccBB); MadeChange = true; - return OptimizeBlock(MBB); + goto ReoptimizeBlock; } } // Okay, there is no really great place to put this block. If, however, // the block before this one would be a fall-through if this block were // removed, move this block to the end of the function. + MachineBasicBlock *PrevTBB, *PrevFBB; + SmallVector PrevCond; if (FallThrough != MF.end() && + !TII->AnalyzeBranch(PrevBB, PrevTBB, PrevFBB, PrevCond, true) && PrevBB.isSuccessor(FallThrough)) { MBB->moveAfter(--MF.end()); MadeChange = true; Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=86871&r1=86870&r2=86871&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Nov 11 13:48:59 2009 @@ -371,10 +371,7 @@ MachineBasicBlock::succ_iterator SI = succ_begin(); MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB; while (SI != succ_end()) { - if (*SI == DestA && DestA == DestB) { - DestA = DestB = 0; - ++SI; - } else if (*SI == DestA) { + if (*SI == DestA) { DestA = 0; ++SI; } else if (*SI == DestB) { Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=86871&r1=86870&r2=86871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Wed Nov 11 13:48:59 2009 @@ -20,7 +20,8 @@ br i1 %a, label %bb11, label %bb9 bb9: ; preds = %bb7 -; CHECK: @ BB#2: +; CHECK: cmp r0, #0 +; CHECK-NEXT: cmp r0, #0 ; CHECK-NEXT: cbnz %0 = tail call arm_apcscc double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt3.ll?rev=86871&r1=86870&r2=86871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt3.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt3.ll Wed Nov 11 13:48:59 2009 @@ -23,7 +23,7 @@ ; CHECK: movne ; CHECK: moveq ; CHECK: pop -; CHECK-NEXT: LBB1_2: +; CHECK-NEXT: LBB1_1: %0 = load i64* @posed, align 4 ; [#uses=3] %1 = sub i64 %0, %.reload78 ; [#uses=1] %2 = ashr i64 %1, 1 ; [#uses=3] Modified: llvm/trunk/test/CodeGen/X86/loop-blocks.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-blocks.ll?rev=86871&r1=86870&r2=86871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-blocks.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-blocks.ll Wed Nov 11 13:48:59 2009 @@ -74,16 +74,16 @@ ; CHECK: yet_more_involved: ; CHECK: jmp .LBB3_1 ; CHECK-NEXT: align -; CHECK-NEXT: .LBB3_3: +; CHECK-NEXT: .LBB3_4: ; CHECK-NEXT: call bar99 ; CHECK-NEXT: call get ; CHECK-NEXT: cmpl $2999, %eax -; CHECK-NEXT: jg .LBB3_5 +; CHECK-NEXT: jg .LBB3_6 ; CHECK-NEXT: call block_a_true_func -; CHECK-NEXT: jmp .LBB3_6 -; CHECK-NEXT: .LBB3_5: -; CHECK-NEXT: call block_a_false_func +; CHECK-NEXT: jmp .LBB3_7 ; CHECK-NEXT: .LBB3_6: +; CHECK-NEXT: call block_a_false_func +; CHECK-NEXT: .LBB3_7: ; CHECK-NEXT: call block_a_merge_func ; CHECK-NEXT: .LBB3_1: ; CHECK-NEXT: call body Added: llvm/trunk/test/CodeGen/X86/tail-opts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-opts.ll?rev=86871&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/tail-opts.ll (added) +++ llvm/trunk/test/CodeGen/X86/tail-opts.ll Wed Nov 11 13:48:59 2009 @@ -0,0 +1,268 @@ +; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -asm-verbose=false | FileCheck %s + +declare void @bar(i32) +declare void @car(i32) +declare void @dar(i32) +declare void @ear(i32) +declare void @far(i32) +declare i1 @qux() + + at GHJK = global i32 0 + at HABC = global i32 0 + +; BranchFolding should tail-merge the stores since they all precede +; direct branches to the same place. + +; CHECK: tail_merge_me: +; CHECK-NOT: GHJK +; CHECK: movl $0, GHJK(%rip) +; CHECK-NEXT: movl $1, HABC(%rip) +; CHECK-NOT: GHJK + +define void @tail_merge_me() nounwind { +entry: + %a = call i1 @qux() + br i1 %a, label %A, label %next +next: + %b = call i1 @qux() + br i1 %b, label %B, label %C + +A: + call void @bar(i32 0) + store i32 0, i32* @GHJK + br label %M + +B: + call void @car(i32 1) + store i32 0, i32* @GHJK + br label %M + +C: + call void @dar(i32 2) + store i32 0, i32* @GHJK + br label %M + +M: + store i32 1, i32* @HABC + %c = call i1 @qux() + br i1 %c, label %return, label %altret + +return: + call void @ear(i32 1000) + ret void +altret: + call void @far(i32 1001) + ret void +} + +declare i8* @choose(i8*, i8*); + +; BranchFolding should tail-duplicate the indirect jump to avoid +; redundant branching. + +; CHECK: tail_duplicate_me: +; CHECK: movl $0, GHJK(%rip) +; CHECK-NEXT: jmpq *%rbx +; CHECK: movl $0, GHJK(%rip) +; CHECK-NEXT: jmpq *%rbx +; CHECK: movl $0, GHJK(%rip) +; CHECK-NEXT: jmpq *%rbx + +define void @tail_duplicate_me() nounwind { +entry: + %a = call i1 @qux() + %c = call i8* @choose(i8* blockaddress(@tail_duplicate_me, %return), + i8* blockaddress(@tail_duplicate_me, %altret)) + br i1 %a, label %A, label %next +next: + %b = call i1 @qux() + br i1 %b, label %B, label %C + +A: + call void @bar(i32 0) + store i32 0, i32* @GHJK + br label %M + +B: + call void @car(i32 1) + store i32 0, i32* @GHJK + br label %M + +C: + call void @dar(i32 2) + store i32 0, i32* @GHJK + br label %M + +M: + indirectbr i8* %c, [label %return, label %altret] + +return: + call void @ear(i32 1000) + ret void +altret: + call void @far(i32 1001) + ret void +} + +; BranchFolding shouldn't try to merge the tails of two blocks +; with only a branch in common, regardless of the fallthrough situation. + +; CHECK: dont_merge_oddly: +; CHECK-NOT: ret +; CHECK: ucomiss %xmm0, %xmm1 +; CHECK-NEXT: jbe .LBB3_3 +; CHECK-NEXT: ucomiss %xmm2, %xmm0 +; CHECK-NEXT: ja .LBB3_4 +; CHECK-NEXT: .LBB3_2: +; CHECK-NEXT: movb $1, %al +; CHECK-NEXT: ret +; CHECK-NEXT: .LBB3_3: +; CHECK-NEXT: ucomiss %xmm2, %xmm1 +; CHECK-NEXT: jbe .LBB3_2 +; CHECK-NEXT: .LBB3_4: +; CHECK-NEXT: xorb %al, %al +; CHECK-NEXT: ret + +define i1 @dont_merge_oddly(float* %result) nounwind { +entry: + %tmp4 = getelementptr float* %result, i32 2 + %tmp5 = load float* %tmp4, align 4 + %tmp7 = getelementptr float* %result, i32 4 + %tmp8 = load float* %tmp7, align 4 + %tmp10 = getelementptr float* %result, i32 6 + %tmp11 = load float* %tmp10, align 4 + %tmp12 = fcmp olt float %tmp8, %tmp11 + br i1 %tmp12, label %bb, label %bb21 + +bb: + %tmp23469 = fcmp olt float %tmp5, %tmp8 + br i1 %tmp23469, label %bb26, label %bb30 + +bb21: + %tmp23 = fcmp olt float %tmp5, %tmp11 + br i1 %tmp23, label %bb26, label %bb30 + +bb26: + ret i1 0 + +bb30: + ret i1 1 +} + +; Do any-size tail-merging when two candidate blocks will both require +; an unconditional jump to complete a two-way conditional branch. + +; CHECK: c_expand_expr_stmt: +; CHECK: jmp .LBB4_7 +; CHECK-NEXT: .LBB4_12: +; CHECK-NEXT: movq 8(%rax), %rax +; CHECK-NEXT: movb 16(%rax), %al +; CHECK-NEXT: cmpb $16, %al +; CHECK-NEXT: je .LBB4_6 +; CHECK-NEXT: cmpb $23, %al +; CHECK-NEXT: je .LBB4_6 +; CHECK-NEXT: jmp .LBB4_15 +; CHECK-NEXT: .LBB4_14: +; CHECK-NEXT: cmpb $23, %bl +; CHECK-NEXT: jne .LBB4_15 +; CHECK-NEXT: .LBB4_15: + +%0 = type { %struct.rtx_def* } +%struct.lang_decl = type opaque +%struct.rtx_def = type { i16, i8, i8, [1 x %union.rtunion] } +%struct.tree_decl = type { [24 x i8], i8*, i32, %union.tree_node*, i32, i8, i8, i8, i8, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %union.tree_node*, %struct.rtx_def*, %union..2anon, %0, %union.tree_node*, %struct.lang_decl* } +%union..2anon = type { i32 } +%union.rtunion = type { i8* } +%union.tree_node = type { %struct.tree_decl } + +define fastcc void @c_expand_expr_stmt(%union.tree_node* %expr) nounwind { +entry: + %tmp4 = load i8* null, align 8 ; [#uses=3] + switch i8 %tmp4, label %bb3 [ + i8 18, label %bb + ] + +bb: ; preds = %entry + switch i32 undef, label %bb1 [ + i32 0, label %bb2.i + i32 37, label %bb.i + ] + +bb.i: ; preds = %bb + switch i32 undef, label %bb1 [ + i32 0, label %lvalue_p.exit + ] + +bb2.i: ; preds = %bb + br label %bb3 + +lvalue_p.exit: ; preds = %bb.i + %tmp21 = load %union.tree_node** null, align 8 ; <%union.tree_node*> [#uses=3] + %tmp22 = getelementptr inbounds %union.tree_node* %tmp21, i64 0, i32 0, i32 0, i64 0 ; [#uses=1] + %tmp23 = load i8* %tmp22, align 8 ; [#uses=1] + %tmp24 = zext i8 %tmp23 to i32 ; [#uses=1] + switch i32 %tmp24, label %lvalue_p.exit4 [ + i32 0, label %bb2.i3 + i32 2, label %bb.i1 + ] + +bb.i1: ; preds = %lvalue_p.exit + %tmp25 = getelementptr inbounds %union.tree_node* %tmp21, i64 0, i32 0, i32 2 ; [#uses=1] + %tmp26 = bitcast i32* %tmp25 to %union.tree_node** ; <%union.tree_node**> [#uses=1] + %tmp27 = load %union.tree_node** %tmp26, align 8 ; <%union.tree_node*> [#uses=2] + %tmp28 = getelementptr inbounds %union.tree_node* %tmp27, i64 0, i32 0, i32 0, i64 16 ; [#uses=1] + %tmp29 = load i8* %tmp28, align 8 ; [#uses=1] + %tmp30 = zext i8 %tmp29 to i32 ; [#uses=1] + switch i32 %tmp30, label %lvalue_p.exit4 [ + i32 0, label %bb2.i.i2 + i32 2, label %bb.i.i + ] + +bb.i.i: ; preds = %bb.i1 + %tmp34 = tail call fastcc i32 @lvalue_p(%union.tree_node* null) nounwind ; [#uses=1] + %phitmp = icmp ne i32 %tmp34, 0 ; [#uses=1] + br label %lvalue_p.exit4 + +bb2.i.i2: ; preds = %bb.i1 + %tmp35 = getelementptr inbounds %union.tree_node* %tmp27, i64 0, i32 0, i32 0, i64 8 ; [#uses=1] + %tmp36 = bitcast i8* %tmp35 to %union.tree_node** ; <%union.tree_node**> [#uses=1] + %tmp37 = load %union.tree_node** %tmp36, align 8 ; <%union.tree_node*> [#uses=1] + %tmp38 = getelementptr inbounds %union.tree_node* %tmp37, i64 0, i32 0, i32 0, i64 16 ; [#uses=1] + %tmp39 = load i8* %tmp38, align 8 ; [#uses=1] + switch i8 %tmp39, label %bb2 [ + i8 16, label %lvalue_p.exit4 + i8 23, label %lvalue_p.exit4 + ] + +bb2.i3: ; preds = %lvalue_p.exit + %tmp40 = getelementptr inbounds %union.tree_node* %tmp21, i64 0, i32 0, i32 0, i64 8 ; [#uses=1] + %tmp41 = bitcast i8* %tmp40 to %union.tree_node** ; <%union.tree_node**> [#uses=1] + %tmp42 = load %union.tree_node** %tmp41, align 8 ; <%union.tree_node*> [#uses=1] + %tmp43 = getelementptr inbounds %union.tree_node* %tmp42, i64 0, i32 0, i32 0, i64 16 ; [#uses=1] + %tmp44 = load i8* %tmp43, align 8 ; [#uses=1] + switch i8 %tmp44, label %bb2 [ + i8 16, label %lvalue_p.exit4 + i8 23, label %lvalue_p.exit4 + ] + +lvalue_p.exit4: ; preds = %bb2.i3, %bb2.i3, %bb2.i.i2, %bb2.i.i2, %bb.i.i, %bb.i1, %lvalue_p.exit + %tmp45 = phi i1 [ %phitmp, %bb.i.i ], [ false, %bb2.i.i2 ], [ false, %bb2.i.i2 ], [ false, %bb.i1 ], [ false, %bb2.i3 ], [ false, %bb2.i3 ], [ false, %lvalue_p.exit ] ; [#uses=1] + %tmp46 = icmp eq i8 %tmp4, 0 ; [#uses=1] + %or.cond = or i1 %tmp45, %tmp46 ; [#uses=1] + br i1 %or.cond, label %bb2, label %bb3 + +bb1: ; preds = %bb2.i.i, %bb.i, %bb + %.old = icmp eq i8 %tmp4, 23 ; [#uses=1] + br i1 %.old, label %bb2, label %bb3 + +bb2: ; preds = %bb1, %lvalue_p.exit4, %bb2.i3, %bb2.i.i2 + br label %bb3 + +bb3: ; preds = %bb2, %bb1, %lvalue_p.exit4, %bb2.i, %entry + %expr_addr.0 = phi %union.tree_node* [ null, %bb2 ], [ %expr, %bb2.i ], [ %expr, %entry ], [ %expr, %bb1 ], [ %expr, %lvalue_p.exit4 ] ; <%union.tree_node*> [#uses=0] + unreachable +} + +declare fastcc i32 @lvalue_p(%union.tree_node* nocapture) nounwind readonly + +declare fastcc %union.tree_node* @default_conversion(%union.tree_node*) nounwind From gohman at apple.com Wed Nov 11 13:49:34 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 19:49:34 -0000 Subject: [llvm-commits] [llvm] r86873 - /llvm/trunk/lib/CodeGen/BranchFolding.h Message-ID: <200911111949.nABJnYak002738@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 13:49:34 2009 New Revision: 86873 URL: http://llvm.org/viewvc/llvm-project?rev=86873&view=rev Log: Check in the changes to this file too. Modified: llvm/trunk/lib/CodeGen/BranchFolding.h Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=86873&r1=86872&r2=86873&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Wed Nov 11 13:49:34 2009 @@ -44,18 +44,24 @@ RegScavenger *RS; bool TailMergeBlocks(MachineFunction &MF); - bool TryMergeBlocks(MachineBasicBlock* SuccBB, - MachineBasicBlock* PredBB); + bool TryTailMergeBlocks(MachineBasicBlock* SuccBB, + MachineBasicBlock* PredBB); void ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst, MachineBasicBlock *NewDest); MachineBasicBlock *SplitMBBAt(MachineBasicBlock &CurMBB, MachineBasicBlock::iterator BBI1); - unsigned ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength); + unsigned ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength, + MachineBasicBlock *SuccBB, + MachineBasicBlock *PredBB); void RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB, MachineBasicBlock* PredBB); unsigned CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB, unsigned maxCommonTailLength); + bool TailDuplicate(MachineBasicBlock *TailBB, + bool PrevFallsThrough, + MachineFunction &MF); + bool OptimizeBranches(MachineFunction &MF); bool OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); From vkutuzov at accesssoftek.com Wed Nov 11 13:53:56 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Wed, 11 Nov 2009 11:53:56 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> <38a0d8450911101625s5e3b7cb0m31ec0ce4d4144dc@mail.gmail.com> Message-ID: Thanks for the review, Rafael. I appreciate that you did it even with all those cosmetic changes there. Sorry for the white spaces in that patch. I'll keep it separate from now on. The updated patch is attached. * StringRef is passed by value; * Removed getArchNameForLLVMArchType; * Fixed strange alignment. * Removed all cosmetic changes from this patch. Is it Ok to submit? Cheers, Viktor ----- Original Message ----- From: "Rafael Espindola" To: "Viktor Kutuzov" Cc: "Commit Messages and Patches for LLVM" Sent: Tuesday, November 10, 2009 4:25 PM Subject: Re: [llvm-commits] [PATCH] LTO code generator options > 2009/11/10 Viktor Kutuzov : >> Is this Ok to submit? > > Small comments: > > * StringRef is normally passed by value. > * Can you put the header reordering and white space in an independent patch? > * Part of the alignment looks strange: > + if (!MAttrs.empty()) > + features.AddFeatures(MAttrs); > * getArchNameForLLVMArchType is not used > >> Best regards, >> Viktor > > Cheers, > -- > Rafael ?vila de Esp?ndola > -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-lto-codegen-target_override-02.diff Type: application/octet-stream Size: 22783 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091111/529ef66c/attachment.obj From dpatel at apple.com Wed Nov 11 13:55:08 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 19:55:08 -0000 Subject: [llvm-commits] [llvm] r86874 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911111955.nABJt86w002938@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 13:55:08 2009 New Revision: 86874 URL: http://llvm.org/viewvc/llvm-project?rev=86874&view=rev Log: If doesSupportDebugInformation() is false then do not try to emit dwarf debug info. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86874&r1=86873&r2=86874&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Nov 11 13:55:08 2009 @@ -1905,6 +1905,9 @@ if (TimePassesIsEnabled) DebugTimer->startTimer(); + if (!MAI->doesSupportDebugInformation()) + return; + DebugInfoFinder DbgFinder; DbgFinder.processModule(*M); From gohman at apple.com Wed Nov 11 13:56:06 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 19:56:06 -0000 Subject: [llvm-commits] [llvm] r86875 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911111956.nABJu6se002982@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 13:56:05 2009 New Revision: 86875 URL: http://llvm.org/viewvc/llvm-project?rev=86875&view=rev Log: Revert this line of 86871. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86875&r1=86874&r2=86875&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 13:56:05 2009 @@ -58,7 +58,7 @@ char BranchFolderPass::ID = 0; -Pass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { +FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { return new BranchFolderPass(DefaultEnableTailMerge); } From nicholas at mxc.ca Wed Nov 11 13:56:16 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 11 Nov 2009 11:56:16 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options: --verbose In-Reply-To: <214DD1AE30F746F5B0086F4773D23D32@andreic6e7fe55> References: <6AE1604EE3EC5F4296C096518C6B77EEF99C4FAA@mail.accesssoftek.com> <7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55> <4C3AAB5F-812D-4811-A1EE-DEF04E0F29EE@apple.com> <214DD1AE30F746F5B0086F4773D23D32@andreic6e7fe55> Message-ID: <4AFB16E0.9040103@mxc.ca> Viktor Kutuzov wrote: > Please find attached the patch without cosmetic changes. Why do you need this? Or rather, when would a user want to specify this? If this is just debugging info, why not use DEBUG() from llvm/Support/Debug.h? Nick > Best regards, > Viktor > > ----- Original Message ----- From: "Eric Christopher" > To: "Viktor Kutuzov" > Cc: "Commit Messages and Patches for LLVM" > Sent: Tuesday, November 10, 2009 1:15 PM > Subject: Re: [llvm-commits] [PATCH] LTO code generator options: --verbose > > > > On Nov 10, 2009, at 1:10 PM, Viktor Kutuzov wrote: > >> > > It'd be easier to look at if there were less cosmetic changes in the > patch. That said, what do you expect this will add? > > -eric > > > ------------------------------------------------------------------------ > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kennethuil at gmail.com Wed Nov 11 13:59:25 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Wed, 11 Nov 2009 19:59:25 -0000 Subject: [llvm-commits] [llvm] r86876 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.h test/CodeGen/X86/bigstructret.ll Message-ID: <200911111959.nABJxPDw003185@zion.cs.uiuc.edu> Author: kennethuil Date: Wed Nov 11 13:59:24 2009 New Revision: 86876 URL: http://llvm.org/viewvc/llvm-project?rev=86876&view=rev Log: x86 users can now return arbitrary sized structs. Structs too large to fit in return registers will be returned through a hidden sret parameter introduced during SelectionDAG construction. Added: llvm/trunk/test/CodeGen/X86/bigstructret.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86876&r1=86875&r2=86876&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed Nov 11 13:59:24 2009 @@ -951,23 +951,23 @@ /// Get the EVTs and ArgFlags collections that represent the return type /// of the given function. This does not require a DAG or a return value, and /// is suitable for use before any DAGs for the function are constructed. -static void getReturnInfo(const Function* F, SmallVectorImpl &OutVTs, +static void getReturnInfo(const Type* ReturnType, + Attributes attr, SmallVectorImpl &OutVTs, SmallVectorImpl &OutFlags, - TargetLowering &TLI) { - const Type* ReturnType = F->getReturnType(); - + TargetLowering &TLI, + SmallVectorImpl *Offsets = 0) { SmallVector ValueVTs; - ComputeValueVTs(TLI, ReturnType, ValueVTs); + ComputeValueVTs(TLI, ReturnType, ValueVTs, Offsets); unsigned NumValues = ValueVTs.size(); if ( NumValues == 0 ) return; for (unsigned j = 0, f = NumValues; j != f; ++j) { EVT VT = ValueVTs[j]; ISD::NodeType ExtendKind = ISD::ANY_EXTEND; - - if (F->paramHasAttr(0, Attribute::SExt)) + + if (attr & Attribute::SExt) ExtendKind = ISD::SIGN_EXTEND; - else if (F->paramHasAttr(0, Attribute::ZExt)) + else if (attr & Attribute::ZExt) ExtendKind = ISD::ZERO_EXTEND; // FIXME: C calling convention requires the return type to be promoted to @@ -975,26 +975,25 @@ // conventions. The frontend should mark functions whose return values // require promoting with signext or zeroext attributes. if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) { - EVT MinVT = TLI.getRegisterType(F->getContext(), MVT::i32); + EVT MinVT = TLI.getRegisterType(ReturnType->getContext(), MVT::i32); if (VT.bitsLT(MinVT)) VT = MinVT; } - unsigned NumParts = TLI.getNumRegisters(F->getContext(), VT); - EVT PartVT = TLI.getRegisterType(F->getContext(), VT); + unsigned NumParts = TLI.getNumRegisters(ReturnType->getContext(), VT); + EVT PartVT = TLI.getRegisterType(ReturnType->getContext(), VT); // 'inreg' on function refers to return value ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); - if (F->paramHasAttr(0, Attribute::InReg)) + if (attr & Attribute::InReg) Flags.setInReg(); // Propagate extension type if any - if (F->paramHasAttr(0, Attribute::SExt)) + if (attr & Attribute::SExt) Flags.setSExt(); - else if (F->paramHasAttr(0, Attribute::ZExt)) + else if (attr & Attribute::ZExt) Flags.setZExt(); - for (unsigned i = 0; i < NumParts; ++i) - { + for (unsigned i = 0; i < NumParts; ++i) { OutVTs.push_back(PartVT); OutFlags.push_back(Flags); } @@ -1004,54 +1003,88 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) { SDValue Chain = getControlRoot(); SmallVector Outs; - for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { + FunctionLoweringInfo &FLI = DAG.getFunctionLoweringInfo(); + + if (!FLI.CanLowerReturn) { + unsigned DemoteReg = FLI.DemoteRegister; + const Function *F = I.getParent()->getParent(); + + // Emit a store of the return value through the virtual register. + // Leave Outs empty so that LowerReturn won't try to load return + // registers the usual way. + SmallVector PtrValueVTs; + ComputeValueVTs(TLI, PointerType::getUnqual(F->getReturnType()), + PtrValueVTs); + + SDValue RetPtr = DAG.getRegister(DemoteReg, PtrValueVTs[0]); + SDValue RetOp = getValue(I.getOperand(0)); + SmallVector ValueVTs; - ComputeValueVTs(TLI, I.getOperand(i)->getType(), ValueVTs); + SmallVector Offsets; + ComputeValueVTs(TLI, I.getOperand(0)->getType(), ValueVTs, &Offsets); unsigned NumValues = ValueVTs.size(); - if (NumValues == 0) continue; - SDValue RetOp = getValue(I.getOperand(i)); - for (unsigned j = 0, f = NumValues; j != f; ++j) { - EVT VT = ValueVTs[j]; - - ISD::NodeType ExtendKind = ISD::ANY_EXTEND; + SmallVector Chains(NumValues); + EVT PtrVT = PtrValueVTs[0]; + for (unsigned i = 0; i != NumValues; ++i) + Chains[i] = DAG.getStore(Chain, getCurDebugLoc(), + SDValue(RetOp.getNode(), RetOp.getResNo() + i), + DAG.getNode(ISD::ADD, getCurDebugLoc(), PtrVT, RetPtr, + DAG.getConstant(Offsets[i], PtrVT)), + NULL, Offsets[i], false, 0); + Chain = DAG.getNode(ISD::TokenFactor, getCurDebugLoc(), + MVT::Other, &Chains[0], NumValues); + } + else { + for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { + SmallVector ValueVTs; + ComputeValueVTs(TLI, I.getOperand(i)->getType(), ValueVTs); + unsigned NumValues = ValueVTs.size(); + if (NumValues == 0) continue; + + SDValue RetOp = getValue(I.getOperand(i)); + for (unsigned j = 0, f = NumValues; j != f; ++j) { + EVT VT = ValueVTs[j]; + + ISD::NodeType ExtendKind = ISD::ANY_EXTEND; + + const Function *F = I.getParent()->getParent(); + if (F->paramHasAttr(0, Attribute::SExt)) + ExtendKind = ISD::SIGN_EXTEND; + else if (F->paramHasAttr(0, Attribute::ZExt)) + ExtendKind = ISD::ZERO_EXTEND; + + // FIXME: C calling convention requires the return type to be promoted to + // at least 32-bit. But this is not necessary for non-C calling + // conventions. The frontend should mark functions whose return values + // require promoting with signext or zeroext attributes. + if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) { + EVT MinVT = TLI.getRegisterType(*DAG.getContext(), MVT::i32); + if (VT.bitsLT(MinVT)) + VT = MinVT; + } - const Function *F = I.getParent()->getParent(); - if (F->paramHasAttr(0, Attribute::SExt)) - ExtendKind = ISD::SIGN_EXTEND; - else if (F->paramHasAttr(0, Attribute::ZExt)) - ExtendKind = ISD::ZERO_EXTEND; + unsigned NumParts = TLI.getNumRegisters(*DAG.getContext(), VT); + EVT PartVT = TLI.getRegisterType(*DAG.getContext(), VT); + SmallVector Parts(NumParts); + getCopyToParts(DAG, getCurDebugLoc(), + SDValue(RetOp.getNode(), RetOp.getResNo() + j), + &Parts[0], NumParts, PartVT, ExtendKind); + + // 'inreg' on function refers to return value + ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); + if (F->paramHasAttr(0, Attribute::InReg)) + Flags.setInReg(); + + // Propagate extension type if any + if (F->paramHasAttr(0, Attribute::SExt)) + Flags.setSExt(); + else if (F->paramHasAttr(0, Attribute::ZExt)) + Flags.setZExt(); - // FIXME: C calling convention requires the return type to be promoted to - // at least 32-bit. But this is not necessary for non-C calling - // conventions. The frontend should mark functions whose return values - // require promoting with signext or zeroext attributes. - if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) { - EVT MinVT = TLI.getRegisterType(*DAG.getContext(), MVT::i32); - if (VT.bitsLT(MinVT)) - VT = MinVT; + for (unsigned i = 0; i < NumParts; ++i) + Outs.push_back(ISD::OutputArg(Flags, Parts[i], /*isfixed=*/true)); } - - unsigned NumParts = TLI.getNumRegisters(*DAG.getContext(), VT); - EVT PartVT = TLI.getRegisterType(*DAG.getContext(), VT); - SmallVector Parts(NumParts); - getCopyToParts(DAG, getCurDebugLoc(), - SDValue(RetOp.getNode(), RetOp.getResNo() + j), - &Parts[0], NumParts, PartVT, ExtendKind); - - // 'inreg' on function refers to return value - ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); - if (F->paramHasAttr(0, Attribute::InReg)) - Flags.setInReg(); - - // Propagate extension type if any - if (F->paramHasAttr(0, Attribute::SExt)) - Flags.setSExt(); - else if (F->paramHasAttr(0, Attribute::ZExt)) - Flags.setZExt(); - - for (unsigned i = 0; i < NumParts; ++i) - Outs.push_back(ISD::OutputArg(Flags, Parts[i], /*isfixed=*/true)); } } @@ -4453,15 +4486,52 @@ MachineBasicBlock *LandingPad) { const PointerType *PT = cast(CS.getCalledValue()->getType()); const FunctionType *FTy = cast(PT->getElementType()); + const Type *RetTy = FTy->getReturnType(); MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); unsigned BeginLabel = 0, EndLabel = 0; TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Args.reserve(CS.arg_size()); - unsigned j = 1; + + // Check whether the function can return without sret-demotion. + SmallVector OutVTs; + SmallVector OutsFlags; + SmallVector Offsets; + getReturnInfo(RetTy, CS.getAttributes().getRetAttributes(), + OutVTs, OutsFlags, TLI, &Offsets); + + + bool CanLowerReturn = TLI.CanLowerReturn(CS.getCallingConv(), + FTy->isVarArg(), OutVTs, OutsFlags, DAG); + + SDValue DemoteStackSlot; + + if (!CanLowerReturn) { + uint64_t TySize = TLI.getTargetData()->getTypeAllocSize( + FTy->getReturnType()); + unsigned Align = TLI.getTargetData()->getPrefTypeAlignment( + FTy->getReturnType()); + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align); + const Type *StackSlotPtrType = PointerType::getUnqual(FTy->getReturnType()); + + DemoteStackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); + Entry.Node = DemoteStackSlot; + Entry.Ty = StackSlotPtrType; + Entry.isSExt = false; + Entry.isZExt = false; + Entry.isInReg = false; + Entry.isSRet = true; + Entry.isNest = false; + Entry.isByVal = false; + Entry.Alignment = Align; + Args.push_back(Entry); + RetTy = Type::getVoidTy(FTy->getContext()); + } + for (CallSite::arg_iterator i = CS.arg_begin(), e = CS.arg_end(); - i != e; ++i, ++j) { + i != e; ++i) { SDValue ArgNode = getValue(*i); Entry.Node = ArgNode; Entry.Ty = (*i)->getType(); @@ -4497,7 +4567,7 @@ isTailCall = false; std::pair Result = - TLI.LowerCallTo(getRoot(), CS.getType(), + TLI.LowerCallTo(getRoot(), RetTy, CS.paramHasAttr(0, Attribute::SExt), CS.paramHasAttr(0, Attribute::ZExt), FTy->isVarArg(), CS.paramHasAttr(0, Attribute::InReg), FTy->getNumParams(), @@ -4511,6 +4581,35 @@ "Null value expected with tail call!"); if (Result.first.getNode()) setValue(CS.getInstruction(), Result.first); + else if (!CanLowerReturn && Result.second.getNode()) { + // The instruction result is the result of loading from the + // hidden sret parameter. + SmallVector PVTs; + const Type *PtrRetTy = PointerType::getUnqual(FTy->getReturnType()); + + ComputeValueVTs(TLI, PtrRetTy, PVTs); + assert(PVTs.size() == 1 && "Pointers should fit in one register"); + EVT PtrVT = PVTs[0]; + unsigned NumValues = OutVTs.size(); + SmallVector Values(NumValues); + SmallVector Chains(NumValues); + + for (unsigned i = 0; i < NumValues; ++i) { + SDValue L = DAG.getLoad(OutVTs[i], getCurDebugLoc(), Result.second, + DAG.getNode(ISD::ADD, getCurDebugLoc(), PtrVT, DemoteStackSlot, + DAG.getConstant(Offsets[i], PtrVT)), + NULL, Offsets[i], false, 1); + Values[i] = L; + Chains[i] = L.getValue(1); + } + SDValue Chain = DAG.getNode(ISD::TokenFactor, getCurDebugLoc(), + MVT::Other, &Chains[0], NumValues); + PendingLoads.push_back(Chain); + + setValue(CS.getInstruction(), DAG.getNode(ISD::MERGE_VALUES, + getCurDebugLoc(), DAG.getVTList(&OutVTs[0], NumValues), + &Values[0], NumValues)); + } // As a special case, a null chain means that a tail call has // been emitted and the DAG root is already updated. if (Result.second.getNode()) @@ -5779,17 +5878,32 @@ SDValue OldRoot = DAG.getRoot(); DebugLoc dl = SDL->getCurDebugLoc(); const TargetData *TD = TLI.getTargetData(); + SmallVector Ins; // Check whether the function can return without sret-demotion. SmallVector OutVTs; SmallVector OutsFlags; - getReturnInfo(&F, OutVTs, OutsFlags, TLI); - // For now, assert and bail out if it can't. - assert(TLI.CanLowerReturn(F.getCallingConv(), F.isVarArg(), OutVTs, OutsFlags, - DAG) && "Cannot fit return value in registers!"); + getReturnInfo(F.getReturnType(), F.getAttributes().getRetAttributes(), + OutVTs, OutsFlags, TLI); + FunctionLoweringInfo &FLI = DAG.getFunctionLoweringInfo(); + + FLI.CanLowerReturn = TLI.CanLowerReturn(F.getCallingConv(), F.isVarArg(), + OutVTs, OutsFlags, DAG); + if (!FLI.CanLowerReturn) { + // Put in an sret pointer parameter before all the other parameters. + SmallVector ValueVTs; + ComputeValueVTs(TLI, PointerType::getUnqual(F.getReturnType()), ValueVTs); + + // NOTE: Assuming that a pointer will never break down to more than one VT + // or one register. + ISD::ArgFlagsTy Flags; + Flags.setSRet(); + EVT RegisterVT = TLI.getRegisterType(*CurDAG->getContext(), ValueVTs[0]); + ISD::InputArg RetArg(Flags, RegisterVT, true); + Ins.push_back(RetArg); + } // Set up the incoming argument description vector. - SmallVector Ins; unsigned Idx = 1; for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I, ++Idx) { @@ -5867,6 +5981,28 @@ // Set up the argument values. unsigned i = 0; Idx = 1; + if (!FLI.CanLowerReturn) { + // Create a virtual register for the sret pointer, and put in a copy + // from the sret argument into it. + SmallVector ValueVTs; + ComputeValueVTs(TLI, PointerType::getUnqual(F.getReturnType()), ValueVTs); + EVT VT = ValueVTs[0]; + EVT RegVT = TLI.getRegisterType(*CurDAG->getContext(), VT); + ISD::NodeType AssertOp = ISD::DELETED_NODE; + SDValue ArgValue = getCopyFromParts(DAG, dl, &InVals[0], 1, RegVT, + VT, AssertOp); + + MachineFunction& MF = SDL->DAG.getMachineFunction(); + MachineRegisterInfo& RegInfo = MF.getRegInfo(); + unsigned SRetReg = RegInfo.createVirtualRegister(TLI.getRegClassFor(RegVT)); + FLI.DemoteRegister = SRetReg; + NewRoot = SDL->DAG.getCopyToReg(NewRoot, SDL->getCurDebugLoc(), SRetReg, ArgValue); + DAG.setRoot(NewRoot); + + // i indexes lowered arguments. Bump it past the hidden sret argument. + // Idx indexes LLVM arguments. Don't touch it. + ++i; + } for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I, ++Idx) { SmallVector ArgValues; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h?rev=86876&r1=86875&r2=86876&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h Wed Nov 11 13:59:24 2009 @@ -90,6 +90,14 @@ MachineFunction *MF; MachineRegisterInfo *RegInfo; + /// CanLowerReturn - true iff the function's return value can be lowered to + /// registers. + bool CanLowerReturn; + + /// DemoteRegister - if CanLowerReturn is false, DemoteRegister is a vreg + /// allocated to hold a pointer to the hidden sret parameter. + unsigned DemoteRegister; + explicit FunctionLoweringInfo(TargetLowering &TLI); /// set - Initialize this FunctionLoweringInfo with the given Function Added: llvm/trunk/test/CodeGen/X86/bigstructret.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bigstructret.ll?rev=86876&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/bigstructret.ll (added) +++ llvm/trunk/test/CodeGen/X86/bigstructret.ll Wed Nov 11 13:59:24 2009 @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=x86 -o %t +; RUN: grep "movl .24601, 12(%ecx)" %t +; RUN: grep "movl .48, 8(%ecx)" %t +; RUN: grep "movl .24, 4(%ecx)" %t +; RUN: grep "movl .12, (%ecx)" %t + +%0 = type { i32, i32, i32, i32 } + +define internal fastcc %0 @ReturnBigStruct() nounwind readnone { +entry: + %0 = insertvalue %0 zeroinitializer, i32 12, 0 + %1 = insertvalue %0 %0, i32 24, 1 + %2 = insertvalue %0 %1, i32 48, 2 + %3 = insertvalue %0 %2, i32 24601, 3 + ret %0 %3 +} + From vkutuzov at accesssoftek.com Wed Nov 11 14:16:07 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Wed, 11 Nov 2009 12:16:07 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options: --verbose References: <6AE1604EE3EC5F4296C096518C6B77EEF99C4FAA@mail.accesssoftek.com><7383326612F04B4DA85C26A2C9A4E6D4@andreic6e7fe55><4C3AAB5F-812D-4811-A1EE-DEF04E0F29EE@apple.com> <214DD1AE30F746F5B0086F4773D23D32@andreic6e7fe55> <4AFB16E0.9040103@mxc.ca> Message-ID: <8CBDD792C4CB4525B8689033B22886D9@andreic6e7fe55> I have been thinking of how people will set up and maintain complex builds with our tools. Once in a while something will go wrong and it should be a way to figure out what's going on behind the scene. The idea is to have a special "verbose" mode for builds trouble shooting. It is a run-time mode, not a debug; the toolchain does the regular things but provides detailed messages along the way. Gold plugin runs other tools, so from this perspective it is helpful to be able to see what exact program get ran with what exact parameters. I planned to add passing the verbose flag (if set) down to the toolchain as well, just wanted to separate patches. Does it make sense? Viktor ----- Original Message ----- From: "Nick Lewycky" To: "Viktor Kutuzov" Cc: "Eric Christopher" ; "Commit Messages and Patches for LLVM" Sent: Wednesday, November 11, 2009 11:56 AM Subject: Re: [llvm-commits] [PATCH] LTO code generator options: --verbose Viktor Kutuzov wrote: > Please find attached the patch without cosmetic changes. Why do you need this? Or rather, when would a user want to specify this? If this is just debugging info, why not use DEBUG() from llvm/Support/Debug.h? Nick > Best regards, > Viktor > > ----- Original Message ----- From: "Eric Christopher" > To: "Viktor Kutuzov" > Cc: "Commit Messages and Patches for LLVM" > Sent: Tuesday, November 10, 2009 1:15 PM > Subject: Re: [llvm-commits] [PATCH] LTO code generator options: --verbose > > > > On Nov 10, 2009, at 1:10 PM, Viktor Kutuzov wrote: > >> > > It'd be easier to look at if there were less cosmetic changes in the > patch. That said, what do you expect this will add? > > -eric > > > ------------------------------------------------------------------------ > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Wed Nov 11 14:54:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 12:54:49 -0800 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <41DF73EA-6ED0-44BB-9084-D8366E11A928@apple.com> References: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> <41DF73EA-6ED0-44BB-9084-D8366E11A928@apple.com> Message-ID: <868FA2F9-9BD6-4370-9CF4-4A71E29F2868@apple.com> On Nov 11, 2009, at 9:42 AM, Bob Wilson wrote: > > On Nov 11, 2009, at 9:22 AM, Jim Grosbach wrote: >> >> Why was the code placement opt unsafe for arm before? I don't recall >> the history there. > > If I remember correctly, it was running after ARMConstantIslandPass when it is not safe to change the size or position of anything. This has been fixed. Evan From evan.cheng at apple.com Wed Nov 11 15:23:40 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 13:23:40 -0800 Subject: [llvm-commits] [llvm] r86791 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: References: <200911110247.nAB2lJjM014802@zion.cs.uiuc.edu> <90A068C9-E8C3-4C2D-B186-838F68F053C0@apple.com> Message-ID: <98E76E15-435B-473F-877F-F55CC4C514A9@apple.com> On Nov 11, 2009, at 9:22 AM, Jim Grosbach wrote: > Yeah, it definitely should be moved. That's one of the things I'm going to do this morning. > > We could do it in the placement optimization pass, but I'm a bit hesitant at this point since a fair bit of the information we may use for determining how and whether to make transformations will be target specific. The ranges of the TB[BH] instructions being the most straightforward example. That may be handleable via target hooks or something, though. Once we have a better handle on the specifics of the heuristics, that should be more apparent. Your concerns are valid. The only reason I think doing it in BB placement is more targets might benefit if any jump taken is to the same direction. It might help branch prediction for more than just ARM. Evan > > Why was the code placement opt unsafe for arm before? I don't recall the history there. > > -Jim > > On Nov 10, 2009, at 11:05 PM, Evan Cheng wrote: > >> Is this done during OptimizeThumb2JumpTables? Then I don't think that would work. It will mess up constant island placements. Perhaps this has to be done before the constant islands part? Or even in the bb placement optimization pass (which should be safe to turn on for ARM now)? >> >> Evan >> >> On Nov 10, 2009, at 6:47 PM, Jim Grosbach wrote: >> >>> Author: grosbach >>> Date: Tue Nov 10 20:47:19 2009 >>> New Revision: 86791 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=86791&view=rev >>> Log: >>> >>> The TBB and TBH instructions for Thumb2 are really handy for jump tables, but >>> can only branch forward. To best take advantage of them, we'd like to adjust >>> the basic blocks around a bit when reasonable. This patch puts basics in place >>> to do that, with a super-simple algorithm for backwards jump table targets that >>> creates a new branch after the jump table which branches backwards. Real >>> heuristics for reordering blocks or other modifications rather than inserting >>> branches will follow. >>> >>> >>> Modified: >>> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86791&r1=86790&r2=86791&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Nov 10 20:47:19 2009 >>> @@ -31,6 +31,7 @@ >>> #include "llvm/ADT/SmallVector.h" >>> #include "llvm/ADT/STLExtras.h" >>> #include "llvm/ADT/Statistic.h" >>> +#include "llvm/Support/CommandLine.h" >>> #include >>> using namespace llvm; >>> >>> @@ -42,6 +43,12 @@ >>> STATISTIC(NumT2CPShrunk, "Number of Thumb2 constantpool instructions shrunk"); >>> STATISTIC(NumT2BrShrunk, "Number of Thumb2 immediate branches shrunk"); >>> STATISTIC(NumCBZ, "Number of CBZ / CBNZ formed"); >>> +STATISTIC(NumJTMoved, "Number of jump table destination blocks moved"); >>> + >>> + >>> +static cl::opt >>> +AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(false), >>> + cl::desc("Adjust basic block layout to better use TB[BH]")); >>> >>> namespace { >>> /// ARMConstantIslands - Due to limited PC-relative displacements, ARM >>> @@ -202,6 +209,8 @@ >>> bool OptimizeThumb2Instructions(MachineFunction &MF); >>> bool OptimizeThumb2Branches(MachineFunction &MF); >>> bool OptimizeThumb2JumpTables(MachineFunction &MF); >>> + MachineBasicBlock *AdjustJTTargetBlockForward(MachineBasicBlock *BB, >>> + MachineBasicBlock *JTBB); >>> >>> unsigned GetOffsetOf(MachineInstr *MI) const; >>> void dumpBBs(); >>> @@ -1560,7 +1569,7 @@ >>> >>> // FIXME: After the tables are shrunk, can we get rid some of the >>> // constantpool tables? >>> - const MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); >>> + MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); >>> const std::vector &JT = MJTI->getJumpTables(); >>> for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) { >>> MachineInstr *MI = T2JumpTables[i]; >>> @@ -1571,10 +1580,33 @@ >>> unsigned JTI = JTOP.getIndex(); >>> assert(JTI < JT.size()); >>> >>> - bool ByteOk = true; >>> - bool HalfWordOk = true; >>> + // We prefer if target blocks for the jump table come after the jump >>> + // instruction so we can use TB[BH]. Loop through the target blocks >>> + // and try to adjust them such that that's true. >>> unsigned JTOffset = GetOffsetOf(MI) + 4; >>> const std::vector &JTBBs = JT[JTI].MBBs; >>> + if (AdjustJumpTableBlocks) { >>> + for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { >>> + MachineBasicBlock *MBB = JTBBs[j]; >>> + unsigned DstOffset = BBOffsets[MBB->getNumber()]; >>> + >>> + if (DstOffset < JTOffset) { >>> + // The destination precedes the switch. Try to move the block forward >>> + // so we have a positive offset. >>> + MachineBasicBlock *NewBB = >>> + AdjustJTTargetBlockForward(MBB, MI->getParent()); >>> + if (NewBB) { >>> + MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); >>> + JTOffset = GetOffsetOf(MI) + 4; >>> + DstOffset = BBOffsets[MBB->getNumber()]; >>> + } >>> + } >>> + } >>> + } >>> + >>> + bool ByteOk = true; >>> + bool HalfWordOk = true; >>> + JTOffset = GetOffsetOf(MI) + 4; >>> for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { >>> MachineBasicBlock *MBB = JTBBs[j]; >>> unsigned DstOffset = BBOffsets[MBB->getNumber()]; >>> @@ -1660,3 +1692,64 @@ >>> >>> return MadeChange; >>> } >>> + >>> +MachineBasicBlock *ARMConstantIslands:: >>> +AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB) >>> +{ >>> + MachineFunction &MF = *BB->getParent(); >>> + >>> + // FIXME: For now, instead of moving the block, we'll create a new block >>> + // immediate following the jump that's an unconditional branch to the >>> + // actual target. This is obviously not what we want for a real solution, >>> + // but it's useful for proof of concept, and it may be a useful fallback >>> + // later for cases where we otherwise can't move a block. >>> + >>> + // Create a new MBB for the code after the jump BB. >>> + MachineBasicBlock *NewBB = >>> + MF.CreateMachineBasicBlock(JTBB->getBasicBlock()); >>> + MachineFunction::iterator MBBI = JTBB; ++MBBI; >>> + MF.insert(MBBI, NewBB); >>> + >>> + // Add an unconditional branch from NewBB to BB. >>> + // There doesn't seem to be meaningful DebugInfo available; this doesn't >>> + // correspond directly to anything in the source. >>> + assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); >>> + BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB); >>> + >>> + // Update the CFG. >>> + NewBB->addSuccessor(BB); >>> + JTBB->removeSuccessor(BB); >>> + JTBB->addSuccessor(NewBB); >>> + >>> + // Update internal data structures to account for the newly inserted MBB. >>> + // This is almost the same as UpdateForInsertedWaterBlock, except that >>> + // the Water goes after OrigBB, not NewBB. >>> + MF.RenumberBlocks(NewBB); >>> + >>> + // Insert a size into BBSizes to align it properly with the (newly >>> + // renumbered) block numbers. >>> + BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); >>> + >>> + // Likewise for BBOffsets. >>> + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); >>> + >>> + // Figure out how large the first NewMBB is. >>> + unsigned NewBBSize = 0; >>> + for (MachineBasicBlock::iterator I = NewBB->begin(), E = NewBB->end(); >>> + I != E; ++I) >>> + NewBBSize += TII->GetInstSizeInBytes(I); >>> + >>> + unsigned NewBBI = NewBB->getNumber(); >>> + unsigned JTBBI = JTBB->getNumber(); >>> + // Set the size of NewBB in BBSizes. >>> + BBSizes[NewBBI] = NewBBSize; >>> + >>> + // ...and adjust BBOffsets for NewBB accordingly. >>> + BBOffsets[NewBBI] = BBOffsets[JTBBI] + BBSizes[JTBBI]; >>> + >>> + // All BBOffsets following these blocks must be modified. >>> + AdjustBBOffsetsAfter(NewBB, 4); >>> + >>> + ++NumJTMoved; >>> + return NewBB; >>> +} >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From bruno.cardoso at gmail.com Wed Nov 11 15:47:30 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Nov 2009 19:47:30 -0200 Subject: [llvm-commits] [llvm] r86651 - /llvm/trunk/lib/Target/Mips/MipsInstrFPU.td In-Reply-To: References: <200911100235.nAA2ZERO012563@zion.cs.uiuc.edu> Message-ID: <275e64e40911111347w49b62e56l9b730629aa1be39d@mail.gmail.com> Hi Chris, On Tue, Nov 10, 2009 at 3:16 AM, Chris Lattner wrote: > > On Nov 9, 2009, at 6:35 PM, Bruno Cardoso Lopes wrote: > >> Author: bruno >> Date: Mon Nov ?9 20:35:13 2009 >> New Revision: 86651 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86651&view=rev >> Log: >> Fix PR5445 > > Hey Bruno, > > FYI -0.0 is not the same as 0.0. Yep, I forgot that, I'll do the right IEEE 754 solution, thanks! :) > -Chris > >> >> Modified: >> ? llvm/trunk/lib/Target/Mips/MipsInstrFPU.td >> >> Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=86651&r1=86650&r2=86651&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) >> +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Mon Nov ?9 20:35:13 2009 >> @@ -281,7 +281,7 @@ >> // Floating Point Patterns >> //===----------------------------------------------------------------------===// >> def fpimm0 : PatLeaf<(fpimm), [{ >> - ?return N->isExactlyValue(+0.0); >> + ?return N->isExactlyValue(+0.0) || N->isExactlyValue(-0.0); >> }]>; >> >> def : Pat<(f32 fpimm0), (MTC1 ZERO)>; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Bruno Cardoso Lopes http://www.brunocardoso.cc From gohman at apple.com Wed Nov 11 15:57:02 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Nov 2009 21:57:02 -0000 Subject: [llvm-commits] [llvm] r86885 - in /llvm/trunk/lib/CodeGen: BranchFolding.cpp BranchFolding.h Message-ID: <200911112157.nABLv2b4007774@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 15:57:02 2009 New Revision: 86885 URL: http://llvm.org/viewvc/llvm-project?rev=86885&view=rev Log: Promote MergePotentialsElt and SameTailElt to be regular classes instead of typedefs for std::pair. This simplifies the type of SameTails, which previously was std::vector >::iterator, MachineBasicBlock::iterator> Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/BranchFolding.h Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86885&r1=86884&r2=86885&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 15:57:02 2009 @@ -429,24 +429,24 @@ TII->InsertBranch(*CurMBB, SuccBB, NULL, SmallVector()); } -static bool MergeCompare(const std::pair &p, - const std::pair &q) { - if (p.first < q.first) - return true; - else if (p.first > q.first) - return false; - else if (p.second->getNumber() < q.second->getNumber()) - return true; - else if (p.second->getNumber() > q.second->getNumber()) - return false; - else { - // _GLIBCXX_DEBUG checks strict weak ordering, which involves comparing - // an object with itself. +bool +BranchFolder::MergePotentialsElt::operator<(const MergePotentialsElt &o) const { + if (getHash() < o.getHash()) + return true; + else if (getHash() > o.getHash()) + return false; + else if (getBlock()->getNumber() < o.getBlock()->getNumber()) + return true; + else if (getBlock()->getNumber() > o.getBlock()->getNumber()) + return false; + else { + // _GLIBCXX_DEBUG checks strict weak ordering, which involves comparing + // an object with itself. #ifndef _GLIBCXX_DEBUG - llvm_unreachable("Predecessor appears twice"); + llvm_unreachable("Predecessor appears twice"); #endif - return false; - } + return false; + } } /// CountTerminators - Count the number of terminators in the given @@ -537,22 +537,23 @@ MPIterator HighestMPIter = prior(MergePotentials.end()); for (MPIterator CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); - CurMPIter!=B && CurMPIter->first == CurHash; + CurMPIter!=B && CurMPIter->getHash() == CurHash; --CurMPIter) { - for (MPIterator I = prior(CurMPIter); I->first == CurHash ; --I) { + for (MPIterator I = prior(CurMPIter); I->getHash() == CurHash ; --I) { unsigned CommonTailLen; - if (ProfitableToMerge(CurMPIter->second, I->second, minCommonTailLength, + if (ProfitableToMerge(CurMPIter->getBlock(), I->getBlock(), + minCommonTailLength, CommonTailLen, TrialBBI1, TrialBBI2, SuccBB, PredBB)) { if (CommonTailLen > maxCommonTailLength) { SameTails.clear(); maxCommonTailLength = CommonTailLen; HighestMPIter = CurMPIter; - SameTails.push_back(std::make_pair(CurMPIter, TrialBBI1)); + SameTails.push_back(SameTailElt(CurMPIter, TrialBBI1)); } if (HighestMPIter == CurMPIter && CommonTailLen == maxCommonTailLength) - SameTails.push_back(std::make_pair(I, TrialBBI2)); + SameTails.push_back(SameTailElt(I, TrialBBI2)); } if (I == B) break; @@ -568,16 +569,16 @@ MachineBasicBlock* PredBB) { MPIterator CurMPIter, B; for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); - CurMPIter->first == CurHash; + CurMPIter->getHash() == CurHash; --CurMPIter) { // Put the unconditional branch back, if we need one. - MachineBasicBlock *CurMBB = CurMPIter->second; + MachineBasicBlock *CurMBB = CurMPIter->getBlock(); if (SuccBB && CurMBB != PredBB) FixTail(CurMBB, SuccBB, TII); if (CurMPIter == B) break; } - if (CurMPIter->first!=CurHash) + if (CurMPIter->getHash() != CurHash) CurMPIter++; MergePotentials.erase(CurMPIter, MergePotentials.end()); } @@ -590,29 +591,30 @@ unsigned TimeEstimate = ~0U; for (i=0, commonTailIndex=0; isecond == PredBB) { + if (SameTails[i].getBlock() == PredBB) { commonTailIndex = i; break; } // Otherwise, make a (fairly bogus) choice based on estimate of // how long it will take the various blocks to execute. - unsigned t = EstimateRuntime(SameTails[i].first->second->begin(), - SameTails[i].second); + unsigned t = EstimateRuntime(SameTails[i].getBlock()->begin(), + SameTails[i].getTailStartPos()); if (t <= TimeEstimate) { TimeEstimate = t; commonTailIndex = i; } } - MachineBasicBlock::iterator BBI = SameTails[commonTailIndex].second; - MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second; + MachineBasicBlock::iterator BBI = + SameTails[commonTailIndex].getTailStartPos(); + MachineBasicBlock *MBB = SameTails[commonTailIndex].getBlock(); DEBUG(errs() << "\nSplitting BB#" << MBB->getNumber() << ", size " << maxCommonTailLength); MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI); - SameTails[commonTailIndex].first->second = newMBB; - SameTails[commonTailIndex].second = newMBB->begin(); + SameTails[commonTailIndex].setBlock(newMBB); + SameTails[commonTailIndex].setTailStartPos(newMBB->begin()); // If we split PredBB, newMBB is the new predecessor. if (PredBB == MBB) @@ -641,22 +643,22 @@ // new branching and as such are very likely to be profitable. if (SuccBB) { if (SuccBB->pred_size() == MergePotentials.size() && - !MergePotentials[0].second->empty()) { + !MergePotentials[0].getBlock()->empty()) { // If all the predecessors have at least one tail instruction in common, // merging is very likely to be a win since it won't require an increase // in static branches, and it will decrease the static instruction count. bool AllPredsMatch = true; MachineBasicBlock::iterator FirstNonTerm; - unsigned MinNumTerms = CountTerminators(MergePotentials[0].second, + unsigned MinNumTerms = CountTerminators(MergePotentials[0].getBlock(), FirstNonTerm); - if (FirstNonTerm != MergePotentials[0].second->end()) { + if (FirstNonTerm != MergePotentials[0].getBlock()->end()) { for (unsigned i = 1, e = MergePotentials.size(); i != e; ++i) { MachineBasicBlock::iterator OtherFirstNonTerm; - unsigned NumTerms = CountTerminators(MergePotentials[0].second, + unsigned NumTerms = CountTerminators(MergePotentials[0].getBlock(), OtherFirstNonTerm); if (NumTerms < MinNumTerms) MinNumTerms = NumTerms; - if (OtherFirstNonTerm == MergePotentials[i].second->end() || + if (OtherFirstNonTerm == MergePotentials[i].getBlock()->end() || OtherFirstNonTerm->isIdenticalTo(FirstNonTerm)) { AllPredsMatch = false; break; @@ -672,7 +674,7 @@ DEBUG(errs() << "\nTryTailMergeBlocks: "; for (unsigned i = 0, e = MergePotentials.size(); i != e; ++i) - errs() << "BB#" << MergePotentials[i].second->getNumber() + errs() << "BB#" << MergePotentials[i].getBlock()->getNumber() << (i == e-1 ? "" : ", "); errs() << "\n"; if (SuccBB) { @@ -688,11 +690,11 @@ // Sort by hash value so that blocks with identical end sequences sort // together. - std::stable_sort(MergePotentials.begin(), MergePotentials.end(),MergeCompare); + std::stable_sort(MergePotentials.begin(), MergePotentials.end()); // Walk through equivalence sets looking for actual exact matches. while (MergePotentials.size() > 1) { - unsigned CurHash = MergePotentials.back().first; + unsigned CurHash = MergePotentials.back().getHash(); // Build SameTails, identifying the set of blocks with this hash code // and with the maximum number of instructions in common. @@ -711,31 +713,30 @@ // block, which we can't jump to), we can treat all blocks with this same // tail at once. Use PredBB if that is one of the possibilities, as that // will not introduce any extra branches. - MachineBasicBlock *EntryBB = MergePotentials.begin()->second-> - getParent()->begin(); - unsigned int commonTailIndex, i; - for (commonTailIndex=SameTails.size(), i=0; isecond; + MachineBasicBlock *EntryBB = MergePotentials.begin()->getBlock()-> + getParent()->begin(); + unsigned commonTailIndex = SameTails.size(); + for (unsigned i=0; ibegin() == SameTails[i].second) + if (MBB->begin() == SameTails[i].getTailStartPos()) commonTailIndex = i; } if (commonTailIndex == SameTails.size() || - (SameTails[commonTailIndex].first->second == PredBB && - SameTails[commonTailIndex].first->second->begin() != - SameTails[i].second)) { + (SameTails[commonTailIndex].getBlock() == PredBB && + !SameTails[commonTailIndex].tailIsWholeBlock())) { // None of the blocks consist entirely of the common tail. // Split a block so that one does. commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength); } - MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second; + MachineBasicBlock *MBB = SameTails[commonTailIndex].getBlock(); // MBB is common tail. Adjust all other BB's to jump to this one. // Traversal must be forwards so erases work. DEBUG(errs() << "\nUsing common tail in BB#" << MBB->getNumber() @@ -743,12 +744,12 @@ for (unsigned int i=0, e = SameTails.size(); i != e; ++i) { if (commonTailIndex == i) continue; - DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() + DEBUG(errs() << "BB#" << SameTails[i].getBlock()->getNumber() << (i == e-1 ? "" : ", ")); // Hack the end off BB i, making it jump to BB commonTailIndex instead. - ReplaceTailWithBranchTo(SameTails[i].second, MBB); + ReplaceTailWithBranchTo(SameTails[i].getTailStartPos(), MBB); // BB i is no longer a predecessor of SuccBB; remove it from the worklist. - MergePotentials.erase(SameTails[i].first); + MergePotentials.erase(SameTails[i].getMPIter()); } DEBUG(errs() << "\n"); // We leave commonTailIndex in the worklist in case there are other blocks @@ -768,7 +769,7 @@ MergePotentials.clear(); for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { if (I->succ_empty()) - MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I)); + MergePotentials.push_back(MergePotentialsElt(HashEndOfMBB(I, 2U), I)); } // See if we can do any tail merging on those. @@ -854,7 +855,8 @@ // reinsert conditional branch only, for now TII->InsertBranch(*PBB, (TBB == IBB) ? FBB : TBB, 0, NewCond); } - MergePotentials.push_back(std::make_pair(HashEndOfMBB(PBB, 1U), *P)); + MergePotentials.push_back(MergePotentialsElt(HashEndOfMBB(PBB, 1U), + *P)); } } if (MergePotentials.size() >= 2) @@ -863,8 +865,8 @@ // The 1 below can occur as a result of removing blocks in TryTailMergeBlocks. PredBB = prior(I); // this may have been changed in TryTailMergeBlocks if (MergePotentials.size() == 1 && - MergePotentials.begin()->second != PredBB) - FixTail(MergePotentials.begin()->second, IBB, TII); + MergePotentials.begin()->getBlock() != PredBB) + FixTail(MergePotentials.begin()->getBlock(), IBB, TII); } } return MadeChange; Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=86885&r1=86884&r2=86885&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Wed Nov 11 15:57:02 2009 @@ -30,11 +30,58 @@ const TargetRegisterInfo *tri, MachineModuleInfo *mmi); private: - typedef std::pair MergePotentialsElt; + class MergePotentialsElt { + unsigned Hash; + MachineBasicBlock *Block; + public: + MergePotentialsElt(unsigned h, MachineBasicBlock *b) + : Hash(h), Block(b) {} + + unsigned getHash() const { return Hash; } + MachineBasicBlock *getBlock() const { return Block; } + + void setBlock(MachineBasicBlock *MBB) { + Block = MBB; + } + + bool operator<(const MergePotentialsElt &) const; + }; typedef std::vector::iterator MPIterator; std::vector MergePotentials; - typedef std::pair SameTailElt; + class SameTailElt { + MPIterator MPIter; + MachineBasicBlock::iterator TailStartPos; + public: + SameTailElt(MPIterator mp, MachineBasicBlock::iterator tsp) + : MPIter(mp), TailStartPos(tsp) {} + + MPIterator getMPIter() const { + return MPIter; + } + MergePotentialsElt &getMergePotentialsElt() const { + return *getMPIter(); + } + MachineBasicBlock::iterator getTailStartPos() const { + return TailStartPos; + } + unsigned getHash() const { + return getMergePotentialsElt().getHash(); + } + MachineBasicBlock *getBlock() const { + return getMergePotentialsElt().getBlock(); + } + bool tailIsWholeBlock() const { + return TailStartPos == getBlock()->begin(); + } + + void setBlock(MachineBasicBlock *MBB) { + getMergePotentialsElt().setBlock(MBB); + } + void setTailStartPos(MachineBasicBlock::iterator Pos) { + TailStartPos = Pos; + } + }; std::vector SameTails; bool EnableTailMerge; From sabre at nondot.org Wed Nov 11 16:31:38 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 22:31:38 -0000 Subject: [llvm-commits] [llvm] r86886 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911112231.nABMVcqO009084@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 16:31:38 2009 New Revision: 86886 URL: http://llvm.org/viewvc/llvm-project?rev=86886&view=rev Log: pass TD into a SimplifyCmpInst call. Add another case that uses LVI info when -enable-jump-threading-lvi is passed. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86886&r1=86885&r2=86886&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 16:31:38 2009 @@ -361,7 +361,7 @@ Value *LHS = PN->getIncomingValue(i); Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); - Value *Res = SimplifyCmpInst(Cmp->getPredicate(), LHS, RHS); + Value *Res = SimplifyCmpInst(Cmp->getPredicate(), LHS, RHS, TD); if (Res == 0) continue; if (isa(Res)) @@ -373,8 +373,29 @@ return !Result.empty(); } - // TODO: We could also recurse to see if we can determine constants another - // way. + + // If comparing a live-in value against a constant, see if we know the + // live-in value on any predecessors. + if (LVI && isa(Cmp->getOperand(1)) && + (!isa(Cmp->getOperand(0)) || + cast(Cmp->getOperand(0))->getParent() != BB)) { + Constant *RHSCst = cast(Cmp->getOperand(1)); + + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + // If the value is known by LazyValueInfo to be a constant in a + // predecessor, use that information to try to thread this block. + Constant *PredCst = LVI->getConstant(Cmp->getOperand(0), *PI); + if (PredCst == 0) + continue; + + // Constant fold the compare. + Value *Res = SimplifyCmpInst(Cmp->getPredicate(), PredCst, RHSCst, TD); + if (isa(Res) || isa(Res)) + Result.push_back(std::make_pair(dyn_cast(Res), *PI)); + } + + return !Result.empty(); + } } return false; } From sabre at nondot.org Wed Nov 11 16:48:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 22:48:44 -0000 Subject: [llvm-commits] [llvm] r86889 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <200911112248.nABMmiJu009704@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 16:48:44 2009 New Revision: 86889 URL: http://llvm.org/viewvc/llvm-project?rev=86889&view=rev Log: make LazyValueInfo actually to some stuff. This isn't very tested but improves strswitch. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86889&r1=86888&r2=86889&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 16:48:44 2009 @@ -17,6 +17,9 @@ #include "llvm/Instructions.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Target/TargetData.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" using namespace llvm; @@ -58,6 +61,12 @@ public: LVILatticeVal() : Val(0, undefined) {} + static LVILatticeVal get(Constant *C) { + LVILatticeVal Res; + Res.markConstant(C); + return Res; + } + bool isUndefined() const { return Val.getInt() == undefined; } bool isConstant() const { return Val.getInt() == constant; } bool isOverdefined() const { return Val.getInt() == overdefined; } @@ -94,12 +103,34 @@ Val.setInt(constant); assert(V && "Marking constant with NULL"); Val.setPointer(V); + return true; + } + + /// mergeIn - Merge the specified lattice value into this one, updating this + /// one and returning true if anything changed. + bool mergeIn(const LVILatticeVal &RHS) { + if (RHS.isUndefined() || isOverdefined()) return false; + if (RHS.isOverdefined()) return markOverdefined(); + + // RHS must be a constant, we must be undef or constant. + if (isConstant() && getConstant() != RHS.getConstant()) + return markOverdefined(); + return markConstant(RHS.getConstant()); } }; } // end anonymous namespace. +namespace llvm { +raw_ostream &operator<<(raw_ostream &OS, const LVILatticeVal &Val) { + if (Val.isUndefined()) + return OS << "undefined"; + if (Val.isOverdefined()) + return OS << "overdefined"; + return OS << "constant<" << *Val.getConstant() << '>'; +} +} //===----------------------------------------------------------------------===// // LazyValueInfo Impl @@ -115,6 +146,127 @@ // No caching yet. } +static LVILatticeVal GetValueInBlock(Value *V, BasicBlock *BB, + DenseMap &); + +static LVILatticeVal GetValueOnEdge(Value *V, BasicBlock *BBFrom, + BasicBlock *BBTo, + DenseMap &BlockVals) { + // FIXME: Pull edge logic out of jump threading. + + + if (BranchInst *BI = dyn_cast(BBFrom->getTerminator())) { + // If this is a conditional branch and only one successor goes to BBTo, then + // we maybe able to infer something from the condition. + if (BI->isConditional() && + BI->getSuccessor(0) != BI->getSuccessor(1)) { + bool isTrueDest = BI->getSuccessor(0) == BBTo; + assert(BI->getSuccessor(!isTrueDest) == BBTo && + "BBTo isn't a successor of BBFrom"); + + // If V is the condition of the branch itself, then we know exactly what + // it is. + if (BI->getCondition() == V) + return LVILatticeVal::get(ConstantInt::get( + Type::getInt1Ty(V->getContext()), isTrueDest)); + + // If the condition of the branch is an equality comparison, we may be + // able to infer the value. + if (ICmpInst *ICI = dyn_cast(BI->getCondition())) + if (ICI->isEquality() && ICI->getOperand(0) == V && + isa(ICI->getOperand(1))) { + // We know that V has the RHS constant if this is a true SETEQ or + // false SETNE. + if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) + return LVILatticeVal::get(cast(ICI->getOperand(1))); + } + } + } + + // TODO: Info from switch. + + + // Otherwise see if the value is known in the block. + return GetValueInBlock(V, BBFrom, BlockVals); +} + +static LVILatticeVal GetValueInBlock(Value *V, BasicBlock *BB, + DenseMap &BlockVals) { + // See if we already have a value for this block. + LVILatticeVal &BBLV = BlockVals[BB]; + + // If we've already computed this block's value, return it. + if (!BBLV.isUndefined()) + return BBLV; + + // Otherwise, this is the first time we're seeing this block. Reset the + // lattice value to overdefined, so that cycles will terminate and be + // conservatively correct. + BBLV.markOverdefined(); + + LVILatticeVal Result; // Start Undefined. + + // If V is live in to BB, see if our predecessors know anything about it. + Instruction *BBI = dyn_cast(V); + if (BBI == 0 || BBI->getParent() != BB) { + unsigned NumPreds = 0; + + // Loop over all of our predecessors, merging what we know from them into + // result. + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + Result.mergeIn(GetValueOnEdge(V, *PI, BB, BlockVals)); + + // If we hit overdefined, exit early. The BlockVals entry is already set + // to overdefined. + if (Result.isOverdefined()) + return Result; + ++NumPreds; + } + + // If this is the entry block, we must be asking about an argument. The + // value is overdefined. + if (NumPreds == 0 && BB == &BB->getParent()->front()) { + assert(isa(V) && "Unknown live-in to the entry block"); + Result.markOverdefined(); + return Result; + } + + // Return the merged value, which is more precise than 'overdefined'. + assert(!Result.isOverdefined()); + return BlockVals[BB] = Result; + } + + // If this value is defined by an instruction in this block, we have to + // process it here somehow or return overdefined. + if (PHINode *PN = dyn_cast(BBI)) { + (void)PN; + // TODO: PHI Translation in preds. + } else { + + } + + Result.markOverdefined(); + return BlockVals[BB] = Result; +} + + +Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) { + // If already a constant, return it. + if (Constant *VC = dyn_cast(V)) + return VC; + + DenseMap BlockValues; + + errs() << "Getting value " << *V << " at end of block '" + << BB->getName() << "'\n"; + LVILatticeVal Result = GetValueInBlock(V, BB, BlockValues); + + errs() << " Result = " << Result << "\n"; + + if (Result.isConstant()) + return Result.getConstant(); + return 0; +} /// isEqual - Determine whether the specified value is known to be equal or /// not-equal to the specified constant at the end of the specified block. @@ -135,12 +287,4 @@ return Unknown; } -Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) { - // If already a constant, return it. - if (Constant *VC = dyn_cast(V)) - return VC; - - // Not a very good implementation. - return 0; -} From bob.wilson at apple.com Wed Nov 11 17:05:45 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Nov 2009 23:05:45 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 11 17:05:45 2009 New Revision: 86892 URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev Log: Fix pr5406: When passing an aggregate in integer registers, the data cannot be split up into integer types smaller than the target registers. Most of the data is put into an array of i32 or i64 values, and that part is OK. But, if the size is not a multiple of 32 or 64, there may be some leftover bytes to be passed separately. Change to pass those leftover bytes in a single integer. The x86_64 target already does this in target-specific code. This also fixes radars 7226380 and 7226213. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=86892&r1=86891&r2=86892&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Nov 11 17:05:45 2009 @@ -629,19 +629,18 @@ Elts.push_back(ATy); } - if (Size >= 4) { + // Put any left over bytes into one last register. This target-independent + // code does not know the size of the argument registers, so use the + // smallest size that will work. + if (Size > 4) { + Elts.push_back(Type::getInt64Ty(getGlobalContext())); + } else if (Size > 2) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { + } else if (Size > 1) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { + } else { Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; } - assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1073,19 +1072,18 @@ Elts.push_back(ATy); } - if (Size >= 4) { + // Put any left over bytes into one last register. This target-independent + // code does not know the size of the argument registers, so use the + // smallest size that will work. + if (Size > 4) { + Elts.push_back(Type::getInt64Ty(getGlobalContext())); + } else if (Size > 2) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { + } else if (Size > 1) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { + } else { Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; } - assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; From bruno.cardoso at gmail.com Wed Nov 11 17:09:33 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Nov 2009 23:09:33 -0000 Subject: [llvm-commits] [llvm] r86895 - /llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Message-ID: <200911112309.nABN9XLg010712@zion.cs.uiuc.edu> Author: bruno Date: Wed Nov 11 17:09:33 2009 New Revision: 86895 URL: http://llvm.org/viewvc/llvm-project?rev=86895&view=rev Log: A real solution for the first part of PR5445 Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=86895&r1=86894&r2=86895&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Wed Nov 11 17:09:33 2009 @@ -281,10 +281,15 @@ // Floating Point Patterns //===----------------------------------------------------------------------===// def fpimm0 : PatLeaf<(fpimm), [{ - return N->isExactlyValue(+0.0) || N->isExactlyValue(-0.0); + return N->isExactlyValue(+0.0); +}]>; + +def fpimm0neg : PatLeaf<(fpimm), [{ + return N->isExactlyValue(-0.0); }]>; def : Pat<(f32 fpimm0), (MTC1 ZERO)>; +def : Pat<(f32 fpimm0neg), (FNEG_S32 (MTC1 ZERO))>; def : Pat<(f32 (sint_to_fp CPURegs:$src)), (CVTS_W32 (MTC1 CPURegs:$src))>; def : Pat<(f64 (sint_to_fp CPURegs:$src)), (CVTD_W32 (MTC1 CPURegs:$src))>; From isanbard at gmail.com Wed Nov 11 17:17:02 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Nov 2009 23:17:02 -0000 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> Author: void Date: Wed Nov 11 17:17:02 2009 New Revision: 86897 URL: http://llvm.org/viewvc/llvm-project?rev=86897&view=rev Log: Don't mark a call as potentially throwing if the function it's calling has the "nounwind" attribute. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=86897&r1=86896&r2=86897&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Wed Nov 11 17:17:02 2009 @@ -490,7 +490,27 @@ for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end(); MI != E; ++MI) { if (!MI->isLabel()) { - SawPotentiallyThrowing |= MI->getDesc().isCall(); + if (MI->getDesc().isCall()) { + // Don't mark a call as potentially throwing if the function it's + // calling is marked "nounwind". + bool DoesNotThrow = false; + for (unsigned OI = 0, OE = MI->getNumOperands(); OI != OE; ++OI) { + const MachineOperand &MO = MI->getOperand(OI); + + if (MO.isGlobal()) { + if (Function *F = dyn_cast(MO.getGlobal())) { + if (F->doesNotThrow()) { + DoesNotThrow = true; + break; + } + } + } + } + + if (!DoesNotThrow) + SawPotentiallyThrowing = true; + } + continue; } From sabre at nondot.org Wed Nov 11 18:36:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 11 Nov 2009 18:36:10 -0600 Subject: [llvm-commits] CVS: llvm-www/Users.html Message-ID: <200911120036.nAC0aAjQ013856@zion.cs.uiuc.edu> Changes in directory llvm-www: Users.html updated: 1.71 -> 1.72 --- Log message: fix broken link --- Diffs of the changes: (+2 -2) Users.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/Users.html diff -u llvm-www/Users.html:1.71 llvm-www/Users.html:1.72 --- llvm-www/Users.html:1.71 Fri Oct 30 10:43:56 2009 +++ llvm-www/Users.html Wed Nov 11 18:35:12 2009 @@ -196,7 +196,7 @@ XMOS Technology - Backend port for their + Backend port for their architecture, also working on multicore codegen support. @@ -583,6 +583,6 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!">
    LLVM Development List
    - Last modified: $Date: 2009/10/30 15:43:56 $ + Last modified: $Date: 2009/11/12 00:35:12 $ From gohman at apple.com Wed Nov 11 18:39:10 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 00:39:10 -0000 Subject: [llvm-commits] [llvm] r86909 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/tail-opts.ll Message-ID: <200911120039.nAC0dA6V013985@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 18:39:10 2009 New Revision: 86909 URL: http://llvm.org/viewvc/llvm-project?rev=86909&view=rev Log: Tail merge at any size when there are two potentials blocks and one can be made to fall through into the other. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/test/CodeGen/X86/tail-opts.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86909&r1=86908&r2=86909&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 18:39:10 2009 @@ -495,6 +495,15 @@ return true; } + // If one of the blocks can be completely merged and happens to be in + // a position where the other could fall through into it, merge any number + // of instructions, because it can be done without a branch. + // TODO: If the blocks are not adjacent, move one of them so that they are? + if (MBB1->isLayoutSuccessor(MBB2) && I2 == MBB2->begin()) + return true; + if (MBB2->isLayoutSuccessor(MBB1) && I1 == MBB1->begin()) + return true; + // If both blocks have an unconditional branch temporarily stripped out, // treat that as an additional common instruction. if (MBB1 != PredBB && MBB2 != PredBB && @@ -716,16 +725,31 @@ MachineBasicBlock *EntryBB = MergePotentials.begin()->getBlock()-> getParent()->begin(); unsigned commonTailIndex = SameTails.size(); - for (unsigned i=0; iisLayoutSuccessor(SameTails[1].getBlock()) && + SameTails[1].tailIsWholeBlock()) + commonTailIndex = 1; + else if (SameTails.size() == 2 && + SameTails[1].getBlock()->isLayoutSuccessor( + SameTails[0].getBlock()) && + SameTails[0].tailIsWholeBlock()) + commonTailIndex = 0; + else { + // Otherwise just pick one, favoring the fall-through predecessor if + // there is one. + for (unsigned i = 0, e = SameTails.size(); i != e; ++i) { + MachineBasicBlock *MBB = SameTails[i].getBlock(); + if (MBB == EntryBB && SameTails[i].tailIsWholeBlock()) + continue; + if (MBB == PredBB) { + commonTailIndex = i; + break; + } + if (SameTails[i].tailIsWholeBlock()) + commonTailIndex = i; } - if (MBB->begin() == SameTails[i].getTailStartPos()) - commonTailIndex = i; } if (commonTailIndex == SameTails.size() || @@ -1049,7 +1073,7 @@ continue; // Don't duplicate into a fall-through predecessor unless its the // only predecessor. - if (&*next(MachineFunction::iterator(PredBB)) == TailBB && + if (PredBB->isLayoutSuccessor(TailBB) && PrevFallsThrough && TailBB->pred_size() != 1) continue; Modified: llvm/trunk/test/CodeGen/X86/tail-opts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-opts.ll?rev=86909&r1=86908&r2=86909&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tail-opts.ll (original) +++ llvm/trunk/test/CodeGen/X86/tail-opts.ll Wed Nov 11 18:39:10 2009 @@ -266,3 +266,30 @@ declare fastcc i32 @lvalue_p(%union.tree_node* nocapture) nounwind readonly declare fastcc %union.tree_node* @default_conversion(%union.tree_node*) nounwind + + +; If one tail merging candidate falls through into the other, +; tail merging is likely profitable regardless of how few +; instructions are involved. This function should have only +; one ret instruction. + +; CHECK: foo: +; CHECK: call func +; CHECK-NEXT: .LBB5_2: +; CHECK-NEXT: addq $8, %rsp +; CHECK-NEXT: ret + +define void @foo(i1* %V) nounwind { +entry: + %t0 = icmp eq i1* %V, null + br i1 %t0, label %return, label %bb + +bb: + call void @func() + ret void + +return: + ret void +} + +declare void @func() From dpatel at apple.com Wed Nov 11 18:50:58 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 Nov 2009 00:50:58 -0000 Subject: [llvm-commits] [llvm] r86914 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/Metadata.h lib/Analysis/DebugInfo.cpp lib/VMCore/Metadata.cpp Message-ID: <200911120050.nAC0owVT014507@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 18:50:58 2009 New Revision: 86914 URL: http://llvm.org/viewvc/llvm-project?rev=86914&view=rev Log: Do not use StringRef in DebugInfo interface. This allows StringRef to skip controversial if(str) check in constructor. Buildbots, wait for corresponding clang and llvm-gcc FE check-ins! Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=86914&r1=86913&r2=86914&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Wed Nov 11 18:50:58 2009 @@ -496,26 +496,26 @@ /// CreateCompileUnit - Create a new descriptor for the specified compile /// unit. DICompileUnit CreateCompileUnit(unsigned LangID, - StringRef Filenae, - StringRef Directory, - StringRef Producer, + const char * Filename, + const char * Directory, + const char * Producer, bool isMain = false, bool isOptimized = false, const char *Flags = "", unsigned RunTimeVer = 0); /// CreateEnumerator - Create a single enumerator value. - DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val); + DIEnumerator CreateEnumerator(const char * Name, uint64_t Val); /// CreateBasicType - Create a basic type like int, float, etc. - DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name, + DIBasicType CreateBasicType(DIDescriptor Context, const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, unsigned Encoding); /// CreateBasicType - Create a basic type like int, float, etc. - DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name, + DIBasicType CreateBasicTypeEx(DIDescriptor Context, const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, Constant *AlignInBits, Constant *OffsetInBits, unsigned Flags, @@ -524,7 +524,7 @@ /// CreateDerivedType - Create a derived type like const qualified type, /// pointer, typedef, etc. DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, @@ -534,7 +534,7 @@ /// CreateDerivedType - Create a derived type like const qualified type, /// pointer, typedef, etc. DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, Constant *AlignInBits, @@ -543,7 +543,7 @@ /// CreateCompositeType - Create a composite type like array, struct, etc. DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, @@ -555,7 +555,7 @@ /// CreateCompositeType - Create a composite type like array, struct, etc. DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, @@ -567,25 +567,25 @@ /// CreateSubprogram - Create a new descriptor for the specified subprogram. /// See comments in DISubprogram for descriptions of these fields. - DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, + DISubprogram CreateSubprogram(DIDescriptor Context, const char * Name, + const char * DisplayName, + const char * LinkageName, DICompileUnit CompileUnit, unsigned LineNo, DIType Type, bool isLocalToUnit, bool isDefinition); /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable - CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, + CreateGlobalVariable(DIDescriptor Context, const char * Name, + const char * DisplayName, + const char * LinkageName, DICompileUnit CompileUnit, unsigned LineNo, DIType Type, bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *GV); /// CreateVariable - Create a new descriptor for the specified variable. DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNo, DIType Type); Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=86914&r1=86913&r2=86914&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Wed Nov 11 18:50:58 2009 @@ -60,6 +60,7 @@ public: static MDString *get(LLVMContext &Context, StringRef Str); + static MDString *get(LLVMContext &Context, const char *Str); StringRef getString() const { return Str; } Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86914&r1=86913&r2=86914&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Nov 11 18:50:58 2009 @@ -653,9 +653,9 @@ /// CreateCompileUnit - Create a new descriptor for the specified compile /// unit. Note that this does not unique compile units within the module. DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID, - StringRef Filename, - StringRef Directory, - StringRef Producer, + const char * Filename, + const char * Directory, + const char * Producer, bool isMain, bool isOptimized, const char *Flags, @@ -677,7 +677,7 @@ } /// CreateEnumerator - Create a single enumerator value. -DIEnumerator DIFactory::CreateEnumerator(StringRef Name, uint64_t Val){ +DIEnumerator DIFactory::CreateEnumerator(const char * Name, uint64_t Val){ Value *Elts[] = { GetTagConstant(dwarf::DW_TAG_enumerator), MDString::get(VMContext, Name), @@ -689,7 +689,7 @@ /// CreateBasicType - Create a basic type like int, float, etc. DIBasicType DIFactory::CreateBasicType(DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, @@ -714,7 +714,7 @@ /// CreateBasicType - Create a basic type like int, float, etc. DIBasicType DIFactory::CreateBasicTypeEx(DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, @@ -741,7 +741,7 @@ /// pointer, typedef, etc. DIDerivedType DIFactory::CreateDerivedType(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, @@ -769,7 +769,7 @@ /// pointer, typedef, etc. DIDerivedType DIFactory::CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, @@ -796,7 +796,7 @@ /// CreateCompositeType - Create a composite type like array, struct, etc. DICompositeType DIFactory::CreateCompositeType(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, uint64_t SizeInBits, @@ -828,7 +828,7 @@ /// CreateCompositeType - Create a composite type like array, struct, etc. DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNumber, Constant *SizeInBits, @@ -861,9 +861,9 @@ /// See comments in DISubprogram for descriptions of these fields. This /// method does not unique the generated descriptors. DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, - StringRef Name, - StringRef DisplayName, - StringRef LinkageName, + const char * Name, + const char * DisplayName, + const char * LinkageName, DICompileUnit CompileUnit, unsigned LineNo, DIType Type, bool isLocalToUnit, @@ -887,9 +887,9 @@ /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable -DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, +DIFactory::CreateGlobalVariable(DIDescriptor Context, const char * Name, + const char * DisplayName, + const char * LinkageName, DICompileUnit CompileUnit, unsigned LineNo, DIType Type,bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *Val) { @@ -921,7 +921,7 @@ /// CreateVariable - Create a new descriptor for the specified variable. DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, + const char * Name, DICompileUnit CompileUnit, unsigned LineNo, DIType Type) { Value *Elts[] = { Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=86914&r1=86913&r2=86914&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Nov 11 18:50:58 2009 @@ -39,6 +39,17 @@ new MDString(Context, Entry.getKey()); } +MDString *MDString::get(LLVMContext &Context, const char *Str) { + LLVMContextImpl *pImpl = Context.pImpl; + StringMapEntry &Entry = + pImpl->MDStringCache.GetOrCreateValue(Str ? StringRef(Str) : StringRef()); + MDString *&S = Entry.getValue(); + if (S) return S; + + return S = + new MDString(Context, Entry.getKey()); +} + //===----------------------------------------------------------------------===// // MDNode implementation. // From dpatel at apple.com Wed Nov 11 18:52:39 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 Nov 2009 00:52:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86916 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200911120052.nAC0qesr014585@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 11 18:52:39 2009 New Revision: 86916 URL: http://llvm.org/viewvc/llvm-project?rev=86916&view=rev Log: Do not use StringRef while using DebugInfo interface. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=86916&r1=86915&r2=86916&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Nov 11 18:52:39 2009 @@ -411,15 +411,14 @@ // Gather location information. expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl)); DIType TyD = getOrCreateType(TREE_TYPE(decl)); - std::string DispName = GV->getNameStr(); + const char *DispName = GV->getNameStr().c_str(); if (DECL_NAME(decl)) { if (IDENTIFIER_POINTER(DECL_NAME(decl))) DispName = IDENTIFIER_POINTER(DECL_NAME(decl)); } DebugFactory.CreateGlobalVariable(getOrCreateCompileUnit(Loc.file), - GV->getNameStr(), - DispName, + DispName, DispName, getLinkageName(decl), getOrCreateCompileUnit(Loc.file), Loc.line, TyD, GV->hasInternalLinkage(), @@ -668,7 +667,7 @@ llvm::DICompositeType FwdDecl = DebugFactory.CreateCompositeType(Tag, findRegion(type), - FwdName, + FwdName.c_str(), getOrCreateCompileUnit(Loc.file), Loc.line, 0, 0, 0, Flags, @@ -1005,8 +1004,8 @@ unsigned ObjcRunTimeVer = 0; if (flag_objc_abi != 0 && flag_objc_abi != -1) ObjcRunTimeVer = flag_objc_abi; - DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName, - Directory, + DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(), + Directory.c_str(), version_string, isMain, optimize, Flags, ObjcRunTimeVer); From dpatel at apple.com Wed Nov 11 18:54:57 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Nov 2009 16:54:57 -0800 Subject: [llvm-commits] [llvm] r83082 - /llvm/trunk/include/llvm/ADT/StringRef.h In-Reply-To: <6a8523d60910300833q21726a80ne0b92d87cbf72588@mail.gmail.com> References: <200909291839.n8TIdv0K005250@zion.cs.uiuc.edu> <5EAC33CE-F7F4-415E-AAE2-D3D090178ACB@apple.com> <9DA16CEF-67EF-449A-870E-9818DA3850CA@apple.com> <77942D29-5F7E-4AE6-B56B-2CE12FF05A02@apple.com> <08828162-224F-46F6-A00A-5C295D19BFE5@apple.com> <3754DE71-073E-4845-9A95-FFF65097080B@apple.com> <6a8523d60910300833q21726a80ne0b92d87cbf72588@mail.gmail.com> Message-ID: <4D0DE085-240A-4D32-9218-C5F9EF8F491E@apple.com> On Oct 30, 2009, at 8:33 AM, Daniel Dunbar wrote: > On Mon, Oct 12, 2009 at 10:16 AM, Devang Patel > wrote: >> OK. I'll update how DebugInfo uses StringRef. > > Hi Devang, > > Has this been done? The original patch here is still in StringRef and > I think it should go away. I updated DebugInfo interface. Unfortunately, now clang (code completion related code) relies on this. Once that code is updated, if (Str) can disappear from StringRef constructor. - Devang From echristo at apple.com Wed Nov 11 19:06:08 2009 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Nov 2009 01:06:08 -0000 Subject: [llvm-commits] [llvm] r86917 - /llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Message-ID: <200911120106.nAC168uN015030@zion.cs.uiuc.edu> Author: echristo Date: Wed Nov 11 19:06:08 2009 New Revision: 86917 URL: http://llvm.org/viewvc/llvm-project?rev=86917&view=rev Log: Fix typo, cleanup whitespace. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp?rev=86917&r1=86916&r2=86917&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Wed Nov 11 19:06:08 2009 @@ -49,23 +49,23 @@ /// ThisAllocated - This is true if this block is currently allocated. If /// not, this can be converted to a FreeRangeHeader. unsigned ThisAllocated : 1; - + /// PrevAllocated - Keep track of whether the block immediately before us is /// allocated. If not, the word immediately before this header is the size /// of the previous block. unsigned PrevAllocated : 1; - + /// BlockSize - This is the size in bytes of this memory block, /// including this header. uintptr_t BlockSize : (sizeof(intptr_t)*CHAR_BIT - 2); - + /// getBlockAfter - Return the memory block immediately after this one. /// MemoryRangeHeader &getBlockAfter() const { return *(MemoryRangeHeader*)((char*)this+BlockSize); } - + /// getFreeBlockBefore - If the block before this one is free, return it, /// otherwise return null. FreeRangeHeader *getFreeBlockBefore() const { @@ -73,15 +73,15 @@ intptr_t PrevSize = ((intptr_t *)this)[-1]; return (FreeRangeHeader*)((char*)this-PrevSize); } - + /// FreeBlock - Turn an allocated block into a free block, adjusting /// bits in the object headers, and adding an end of region memory block. FreeRangeHeader *FreeBlock(FreeRangeHeader *FreeList); - + /// TrimAllocationToSize - If this allocated block is significantly larger /// than NewSize, split it into two pieces (where the former is NewSize /// bytes, including the header), and add the new block to the free list. - FreeRangeHeader *TrimAllocationToSize(FreeRangeHeader *FreeList, + FreeRangeHeader *TrimAllocationToSize(FreeRangeHeader *FreeList, uint64_t NewSize); }; @@ -91,13 +91,13 @@ struct FreeRangeHeader : public MemoryRangeHeader { FreeRangeHeader *Prev; FreeRangeHeader *Next; - + /// getMinBlockSize - Get the minimum size for a memory block. Blocks /// smaller than this size cannot be created. static unsigned getMinBlockSize() { return sizeof(FreeRangeHeader)+sizeof(intptr_t); } - + /// SetEndOfBlockSizeMarker - The word at the end of every free block is /// known to be the size of the free block. Set it for this block. void SetEndOfBlockSizeMarker() { @@ -110,7 +110,7 @@ Next->Prev = Prev; return Prev->Next = Next; } - + void AddToFreeList(FreeRangeHeader *FreeList) { Next = FreeList; Prev = FreeList->Prev; @@ -121,7 +121,7 @@ /// GrowBlock - The block after this block just got deallocated. Merge it /// into the current block. void GrowBlock(uintptr_t NewSize); - + /// AllocateBlock - Mark this entire block allocated, updating freelists /// etc. This returns a pointer to the circular free-list. FreeRangeHeader *AllocateBlock(); @@ -137,7 +137,7 @@ // Mark this block allocated. ThisAllocated = 1; getBlockAfter().PrevAllocated = 1; - + // Remove it from the free list. return RemoveFromFreeList(); } @@ -150,9 +150,9 @@ MemoryRangeHeader *FollowingBlock = &getBlockAfter(); assert(ThisAllocated && "This block is already free!"); assert(FollowingBlock->PrevAllocated && "Flags out of sync!"); - + FreeRangeHeader *FreeListToReturn = FreeList; - + // If the block after this one is free, merge it into this block. if (!FollowingBlock->ThisAllocated) { FreeRangeHeader &FollowingFreeBlock = *(FreeRangeHeader *)FollowingBlock; @@ -164,18 +164,18 @@ assert(&FollowingFreeBlock != FreeList && "No tombstone block?"); } FollowingFreeBlock.RemoveFromFreeList(); - + // Include the following block into this one. BlockSize += FollowingFreeBlock.BlockSize; FollowingBlock = &FollowingFreeBlock.getBlockAfter(); - + // Tell the block after the block we are coalescing that this block is // allocated. FollowingBlock->PrevAllocated = 1; } - + assert(FollowingBlock->ThisAllocated && "Missed coalescing?"); - + if (FreeRangeHeader *PrevFreeBlock = getFreeBlockBefore()) { PrevFreeBlock->GrowBlock(PrevFreeBlock->BlockSize + BlockSize); return FreeListToReturn ? FreeListToReturn : PrevFreeBlock; @@ -218,24 +218,24 @@ // Round up size for alignment of header. unsigned HeaderAlign = __alignof(FreeRangeHeader); NewSize = (NewSize+ (HeaderAlign-1)) & ~(HeaderAlign-1); - + // Size is now the size of the block we will remove from the start of the // current block. assert(NewSize <= BlockSize && "Allocating more space from this block than exists!"); - + // If splitting this block will cause the remainder to be too small, do not // split the block. if (BlockSize <= NewSize+FreeRangeHeader::getMinBlockSize()) return FreeList; - + // Otherwise, we splice the required number of bytes out of this block, form // a new block immediately after it, then mark this block allocated. MemoryRangeHeader &FormerNextBlock = getBlockAfter(); - + // Change the size of this block. BlockSize = NewSize; - + // Get the new block we just sliced out and turn it into a free block. FreeRangeHeader &NewNextBlock = (FreeRangeHeader &)getBlockAfter(); NewNextBlock.BlockSize = (char*)&FormerNextBlock - (char*)&NewNextBlock; @@ -283,7 +283,7 @@ sys::MemoryBlock LastSlab; // Memory slabs allocated by the JIT. We refer to them as slabs so we don't - // confuse them with the blocks of memory descibed above. + // confuse them with the blocks of memory described above. std::vector CodeSlabs; JITSlabAllocator BumpSlabAllocator; BumpPtrAllocator StubAllocator; @@ -347,7 +347,7 @@ } largest = largest - sizeof(MemoryRangeHeader); - + // If this block isn't big enough for the allocation desired, allocate // another block of memory and add it to the free list. if (largest < ActualSize || @@ -443,30 +443,30 @@ return (uint8_t*)DataAllocator.Allocate(Size, Alignment); } - /// startExceptionTable - Use startFunctionBody to allocate memory for the + /// startExceptionTable - Use startFunctionBody to allocate memory for the /// function's exception table. uint8_t* startExceptionTable(const Function* F, uintptr_t &ActualSize) { return startFunctionBody(F, ActualSize); } - /// endExceptionTable - The exception table of F is now allocated, + /// endExceptionTable - The exception table of F is now allocated, /// and takes the memory in the range [TableStart,TableEnd). void endExceptionTable(const Function *F, uint8_t *TableStart, uint8_t *TableEnd, uint8_t* FrameRegister) { assert(TableEnd > TableStart); assert(TableStart == (uint8_t *)(CurBlock+1) && "Mismatched table start/end!"); - + uintptr_t BlockSize = TableEnd - (uint8_t *)CurBlock; // Release the memory at the end of this block that isn't needed. FreeMemoryList =CurBlock->TrimAllocationToSize(FreeMemoryList, BlockSize); } - + uint8_t *getGOTBase() const { return GOTBase; } - + void deallocateBlock(void *Block) { // Find the block that is allocated for this function. MemoryRangeHeader *MemRange = static_cast(Block) - 1; @@ -555,16 +555,16 @@ // END ] // // The last three blocks are never deallocated or touched. - + // Add MemoryRangeHeader to the end of the memory region, indicating that // the space after the block of memory is allocated. This is block #3. MemoryRangeHeader *Mem3 = (MemoryRangeHeader*)(MemBase+MemBlock.size())-1; Mem3->ThisAllocated = 1; Mem3->PrevAllocated = 0; Mem3->BlockSize = sizeof(MemoryRangeHeader); - + /// Add a tiny free region so that the free list always has one entry. - FreeRangeHeader *Mem2 = + FreeRangeHeader *Mem2 = (FreeRangeHeader *)(((char*)Mem3)-FreeRangeHeader::getMinBlockSize()); Mem2->ThisAllocated = 0; Mem2->PrevAllocated = 1; @@ -578,7 +578,7 @@ Mem1->ThisAllocated = 1; Mem1->PrevAllocated = 0; Mem1->BlockSize = sizeof(MemoryRangeHeader); - + // Add a FreeRangeHeader to the start of the function body region, indicating // that the space is free. Mark the previous block allocated so we never look // at it. @@ -588,7 +588,7 @@ Mem0->BlockSize = (char*)Mem1-(char*)Mem0; Mem0->SetEndOfBlockSizeMarker(); Mem0->AddToFreeList(Mem2); - + // Start out with the freelist pointing to Mem0. FreeMemoryList = Mem0; From sabre at nondot.org Wed Nov 11 19:22:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 01:22:16 -0000 Subject: [llvm-commits] [llvm] r86918 - in /llvm/trunk: lib/Analysis/LazyValueInfo.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911120122.nAC1MGJ7015549@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 19:22:16 2009 New Revision: 86918 URL: http://llvm.org/viewvc/llvm-project?rev=86918&view=rev Log: move some stuff into DEBUG's and turn on lazy-value-info for the basic.ll testcase. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86918&r1=86917&r2=86918&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 19:22:16 2009 @@ -12,12 +12,14 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "lazy-value-info" #include "llvm/Analysis/LazyValueInfo.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" @@ -257,11 +259,11 @@ DenseMap BlockValues; - errs() << "Getting value " << *V << " at end of block '" - << BB->getName() << "'\n"; + DEBUG(errs() << "Getting value " << *V << " at end of block '" + << BB->getName() << "'\n"); LVILatticeVal Result = GetValueInBlock(V, BB, BlockValues); - errs() << " Result = " << Result << "\n"; + DEBUG(errs() << " Result = " << Result << "\n"); if (Result.isConstant()) return Result.getConstant(); Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86918&r1=86917&r2=86918&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Wed Nov 11 19:22:16 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -jump-threading -S | FileCheck %s +; RUN: opt %s -jump-threading -S -enable-jump-threading-lvi | FileCheck %s declare i32 @f1() declare i32 @f2() From lhames at gmail.com Wed Nov 11 19:24:08 2009 From: lhames at gmail.com (Lang Hames) Date: Thu, 12 Nov 2009 01:24:08 -0000 Subject: [llvm-commits] [llvm] r86919 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Message-ID: <200911120124.nAC1O8AQ015610@zion.cs.uiuc.edu> Author: lhames Date: Wed Nov 11 19:24:08 2009 New Revision: 86919 URL: http://llvm.org/viewvc/llvm-project?rev=86919&view=rev Log: Fixed an iteration condition in PreAllocSplitting. This should fix some miscompilations casued by PreAllocSplitting. Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=86919&r1=86918&r2=86919&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Wed Nov 11 19:24:08 2009 @@ -1400,7 +1400,7 @@ // Otherwise, this is a load-store case, so DCE them. for (SmallPtrSet::iterator UI = VNUseCount[CurrVN].begin(), UE = VNUseCount[CurrVN].end(); - UI != UI; ++UI) { + UI != UE; ++UI) { LIs->RemoveMachineInstrFromMaps(*UI); (*UI)->eraseFromParent(); } From sabre at nondot.org Wed Nov 11 19:29:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 01:29:10 -0000 Subject: [llvm-commits] [llvm] r86920 - in /llvm/trunk: include/llvm/Analysis/LazyValueInfo.h lib/Analysis/LazyValueInfo.cpp lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911120129.nAC1TBHO015818@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 19:29:10 2009 New Revision: 86920 URL: http://llvm.org/viewvc/llvm-project?rev=86920&view=rev Log: expose edge information and switch j-t to use it. Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h llvm/trunk/lib/Analysis/LazyValueInfo.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=86920&r1=86919&r2=86920&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Wed Nov 11 19:29:10 2009 @@ -47,6 +47,10 @@ /// getConstant - Determine whether the specified value is known to be a /// constant at the end of the specified block. Return null if not. Constant *getConstant(Value *V, BasicBlock *BB); + + /// getConstantOnEdge - Determine whether the specified value is known to be a + /// constant on the specified edge. Return null if not. + Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB); // Implementation boilerplate. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86920&r1=86919&r2=86920&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 19:29:10 2009 @@ -270,6 +270,27 @@ return 0; } +/// getConstantOnEdge - Determine whether the specified value is known to be a +/// constant on the specified edge. Return null if not. +Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB, + BasicBlock *ToBB) { + // If already a constant, return it. + if (Constant *VC = dyn_cast(V)) + return VC; + + DenseMap BlockValues; + + DEBUG(errs() << "Getting value " << *V << " on edge from '" + << FromBB->getName() << "' to '" << ToBB->getName() << "'\n"); + LVILatticeVal Result = GetValueOnEdge(V, FromBB, ToBB, BlockValues); + + DEBUG(errs() << " Result = " << Result << "\n"); + + if (Result.isConstant()) + return Result.getConstant(); + return 0; +} + /// isEqual - Determine whether the specified value is known to be equal or /// not-equal to the specified constant at the end of the specified block. LazyValueInfo::Tristate Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86920&r1=86919&r2=86920&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 19:29:10 2009 @@ -278,7 +278,7 @@ for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { // If the value is known by LazyValueInfo to be a constant in a // predecessor, use that information to try to thread this block. - Constant *PredCst = LVI->getConstant(V, *PI); + Constant *PredCst = LVI->getConstantOnEdge(V, *PI, BB); if (PredCst == 0 || (!isa(PredCst) && !isa(PredCst))) continue; @@ -384,7 +384,7 @@ for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { // If the value is known by LazyValueInfo to be a constant in a // predecessor, use that information to try to thread this block. - Constant *PredCst = LVI->getConstant(Cmp->getOperand(0), *PI); + Constant *PredCst = LVI->getConstantOnEdge(Cmp->getOperand(0), *PI, BB); if (PredCst == 0) continue; From sabre at nondot.org Wed Nov 11 19:37:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 01:37:43 -0000 Subject: [llvm-commits] [llvm] r86923 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911120137.nAC1bhvh016170@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 19:37:43 2009 New Revision: 86923 URL: http://llvm.org/viewvc/llvm-project?rev=86923&view=rev Log: this argument can be an arbitrary value, it doesn't need to be an instruction. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86923&r1=86922&r2=86923&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 19:37:43 2009 @@ -95,7 +95,7 @@ bool ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, PredValueInfo &Result); - bool ProcessThreadableEdges(Instruction *CondInst, BasicBlock *BB); + bool ProcessThreadableEdges(Value *Cond, BasicBlock *BB); bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); @@ -927,15 +927,14 @@ return MostPopularDest; } -bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst, - BasicBlock *BB) { +bool JumpThreading::ProcessThreadableEdges(Value *Cond, BasicBlock *BB) { // If threading this would thread across a loop header, don't even try to // thread the edge. if (LoopHeaders.count(BB)) return false; SmallVector, 8> PredValues; - if (!ComputeValueKnownInPredecessors(CondInst, BB, PredValues)) + if (!ComputeValueKnownInPredecessors(Cond, BB, PredValues)) return false; assert(!PredValues.empty() && "ComputeValueKnownInPredecessors returned true with no values"); From sabre at nondot.org Wed Nov 11 19:41:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 01:41:34 -0000 Subject: [llvm-commits] [llvm] r86924 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911120141.nAC1fYPh016312@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 19:41:34 2009 New Revision: 86924 URL: http://llvm.org/viewvc/llvm-project?rev=86924&view=rev Log: with the new code we can thread non-instruction values. This allows us to handle the test10 testcase. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86924&r1=86923&r2=86924&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 19:41:34 2009 @@ -518,8 +518,13 @@ } // All the rest of our checks depend on the condition being an instruction. - if (CondInst == 0) + if (CondInst == 0) { + // FIXME: Unify this with code below. + if (LVI && ProcessThreadableEdges(Condition, BB)) + return true; return false; + } + // See if this is a phi node in the current block. if (PHINode *PN = dyn_cast(CondInst)) Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86924&r1=86923&r2=86924&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Wed Nov 11 19:41:34 2009 @@ -285,12 +285,50 @@ +; CHECK: @test10 +declare i32 @test10f1() +declare i32 @test10f2() +declare void @test10f3() + +;; Non-local condition threading. +define i32 @test10(i1 %cond) { +; CHECK: @test10 +; CHECK-NEXT: br i1 %cond, label %T2, label %F2 + br i1 %cond, label %T1, label %F1 + +T1: + %v1 = call i32 @test10f1() + br label %Merge + +; CHECK: %v1 = call i32 @test10f1() +; CHECK-NEXT: call void @f3() +; CHeCK-NEXT: ret i32 %v1 + +F1: + %v2 = call i32 @test10f2() + br label %Merge + +Merge: + %B = phi i32 [%v1, %T1], [%v2, %F1] + br i1 %cond, label %T2, label %F2 + +T2: + call void @f3() + ret i32 %B + +F2: + ret i32 %B +} + + + + ;;; Duplicate condition to avoid xor of cond. ;;; TODO: Make this happen. -define i32 @test10(i1 %cond, i1 %cond2) { +define i32 @test11(i1 %cond, i1 %cond2) { Entry: -; CHECK: @test10 +; CHECK: @test11 %v1 = call i32 @f1() br i1 %cond, label %Merge, label %F1 From gohman at apple.com Wed Nov 11 19:51:28 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 01:51:28 -0000 Subject: [llvm-commits] [llvm] r86926 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911120151.nAC1pSCS016692@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 19:51:28 2009 New Revision: 86926 URL: http://llvm.org/viewvc/llvm-project?rev=86926&view=rev Log: Minor code cleanups. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86926&r1=86925&r2=86926&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 19:51:28 2009 @@ -380,7 +380,7 @@ RS->forward(prior(CurMBB.end())); BitVector RegsLiveAtExit(TRI->getNumRegs()); RS->getRegsUsed(RegsLiveAtExit, false); - for (unsigned int i=0, e=TRI->getNumRegs(); i!=e; i++) + for (unsigned int i = 0, e = TRI->getNumRegs(); i != e; i++) if (RegsLiveAtExit[i]) NewMBB->addLiveIn(i); } @@ -546,7 +546,7 @@ MPIterator HighestMPIter = prior(MergePotentials.end()); for (MPIterator CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); - CurMPIter!=B && CurMPIter->getHash() == CurHash; + CurMPIter != B && CurMPIter->getHash() == CurHash; --CurMPIter) { for (MPIterator I = prior(CurMPIter); I->getHash() == CurHash ; --I) { unsigned CommonTailLen; @@ -596,9 +596,9 @@ /// only of the common tail. Create a block that does by splitting one. unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB, unsigned maxCommonTailLength) { - unsigned i, commonTailIndex; + unsigned commonTailIndex = 0; unsigned TimeEstimate = ~0U; - for (i=0, commonTailIndex=0; iisLandingPad()) { MachineFunction::iterator IP = PBB; IP++; MachineBasicBlock* PredNextBB = NULL; - if (IP!=MF.end()) + if (IP != MF.end()) PredNextBB = IP; if (TBB == NULL) { - if (IBB!=PredNextBB) // fallthrough + if (IBB != PredNextBB) // fallthrough continue; } else if (FBB) { - if (TBB!=IBB && FBB!=IBB) // cbr then ubr + if (TBB != IBB && FBB != IBB) // cbr then ubr continue; } else if (Cond.empty()) { - if (TBB!=IBB) // ubr + if (TBB != IBB) // ubr continue; } else { - if (TBB!=IBB && IBB!=PredNextBB) // cbr + if (TBB != IBB && IBB != PredNextBB) // cbr continue; } } From sabre at nondot.org Wed Nov 11 19:55:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 01:55:21 -0000 Subject: [llvm-commits] [llvm] r86927 - /llvm/trunk/test/Transforms/JumpThreading/basic.ll Message-ID: <200911120155.nAC1tLii016817@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 19:55:20 2009 New Revision: 86927 URL: http://llvm.org/viewvc/llvm-project?rev=86927&view=rev Log: We now thread some impossible condition information with LVI. Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86927&r1=86926&r2=86927&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Wed Nov 11 19:55:20 2009 @@ -321,14 +321,42 @@ } +; Impossible conditional constraints should get threaded. BB3 is dead here. +define i32 @test11(i32 %A) { +; CHECK: @test11 +; CHECK-NEXT: icmp +; CHECK-NEXT: br i1 %tmp455, label %BB4, label %BB2 + %tmp455 = icmp eq i32 %A, 42 + br i1 %tmp455, label %BB1, label %BB2 + +BB2: +; CHECK: call i32 @f1() +; CHECK-NEXT: call void @f3() +; CHECK-NEXT: ret i32 4 + %C = call i32 @f1() + ret i32 %C + + +BB1: + %tmp459 = icmp eq i32 %A, 43 + br i1 %tmp459, label %BB3, label %BB4 + +BB3: + call i32 @f2() + ret i32 3 + +BB4: + call void @f3() + ret i32 4 +} ;;; Duplicate condition to avoid xor of cond. ;;; TODO: Make this happen. -define i32 @test11(i1 %cond, i1 %cond2) { +define i32 @testXX(i1 %cond, i1 %cond2) { Entry: -; CHECK: @test11 +; CHECK: @testXX %v1 = call i32 @f1() br i1 %cond, label %Merge, label %F1 From gohman at apple.com Wed Nov 11 19:59:26 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 01:59:26 -0000 Subject: [llvm-commits] [llvm] r86928 - in /llvm/trunk/lib/CodeGen: BranchFolding.cpp BranchFolding.h Message-ID: <200911120159.nAC1xQeO016969@zion.cs.uiuc.edu> Author: djg Date: Wed Nov 11 19:59:26 2009 New Revision: 86928 URL: http://llvm.org/viewvc/llvm-project?rev=86928&view=rev Log: Make the BranchFolderPass class local to BranchFolding.cpp. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/BranchFolding.h Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=86928&r1=86927&r2=86928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Nov 11 19:59:26 2009 @@ -56,6 +56,20 @@ cl::desc("Min number of instructions to consider tail merging"), cl::init(3), cl::Hidden); +namespace { + /// BranchFolderPass - Wrap branch folder in a machine function pass. + class BranchFolderPass : public MachineFunctionPass, + public BranchFolder { + public: + static char ID; + explicit BranchFolderPass(bool defaultEnableTailMerge) + : MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {} + + virtual bool runOnMachineFunction(MachineFunction &MF); + virtual const char *getPassName() const { return "Control Flow Optimizer"; } + }; +} + char BranchFolderPass::ID = 0; FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=86928&r1=86927&r2=86928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Wed Nov 11 19:59:26 2009 @@ -11,7 +11,6 @@ #define LLVM_CODEGEN_BRANCHFOLDING_HPP #include "llvm/CodeGen/MachineBasicBlock.h" -#include "llvm/CodeGen/MachineFunctionPass.h" #include namespace llvm { @@ -20,6 +19,7 @@ class RegScavenger; class TargetInstrInfo; class TargetRegisterInfo; + template class SmallVectorImpl; class BranchFolder { public: @@ -119,19 +119,6 @@ MachineBasicBlock *TBB, MachineBasicBlock *FBB, const SmallVectorImpl &Cond); }; - - - /// BranchFolderPass - Wrap branch folder in a machine function pass. - class BranchFolderPass : public MachineFunctionPass, - public BranchFolder { - public: - static char ID; - explicit BranchFolderPass(bool defaultEnableTailMerge) - : MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {} - - virtual bool runOnMachineFunction(MachineFunction &MF); - virtual const char *getPassName() const { return "Control Flow Optimizer"; } - }; } #endif /* LLVM_CODEGEN_BRANCHFOLDING_HPP */ From sabre at nondot.org Wed Nov 11 20:04:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 02:04:17 -0000 Subject: [llvm-commits] [llvm] r86929 - /llvm/trunk/test/Transforms/JumpThreading/basic.ll Message-ID: <200911120204.nAC24HkE017148@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 20:04:17 2009 New Revision: 86929 URL: http://llvm.org/viewvc/llvm-project?rev=86929&view=rev Log: should not commit when distracted. Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86929&r1=86928&r2=86929&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Wed Nov 11 20:04:17 2009 @@ -291,8 +291,8 @@ declare void @test10f3() ;; Non-local condition threading. -define i32 @test10(i1 %cond) { -; CHECK: @test10 +define i32 @test10g(i1 %cond) { +; CHECK: @test10g ; CHECK-NEXT: br i1 %cond, label %T2, label %F2 br i1 %cond, label %T1, label %F1 @@ -331,8 +331,7 @@ BB2: ; CHECK: call i32 @f1() -; CHECK-NEXT: call void @f3() -; CHECK-NEXT: ret i32 4 +; CHECK-NEXT: ret i32 %C %C = call i32 @f1() ret i32 %C From nicholas at mxc.ca Wed Nov 11 20:08:11 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 12 Nov 2009 02:08:11 -0000 Subject: [llvm-commits] [llvm] r86930 - /llvm/trunk/include/llvm/InstrTypes.h Message-ID: <200911120208.nAC28B3J017264@zion.cs.uiuc.edu> Author: nicholas Date: Wed Nov 11 20:08:11 2009 New Revision: 86930 URL: http://llvm.org/viewvc/llvm-project?rev=86930&view=rev Log: Add CreateNUWAdd and CreateNUWSub to complement the existing CreateNSWAdd and CreateNSWSub functions. Modified: llvm/trunk/include/llvm/InstrTypes.h Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=86930&r1=86929&r2=86930&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Wed Nov 11 20:08:11 2009 @@ -214,6 +214,27 @@ return BO; } + /// CreateNUWAdd - Create an Add operator with the NUW flag set. + /// + static BinaryOperator *CreateNUWAdd(Value *V1, Value *V2, + const Twine &Name = "") { + BinaryOperator *BO = CreateAdd(V1, V2, Name); + BO->setHasNoUnsignedWrap(true); + return BO; + } + static BinaryOperator *CreateNUWAdd(Value *V1, Value *V2, + const Twine &Name, BasicBlock *BB) { + BinaryOperator *BO = CreateAdd(V1, V2, Name, BB); + BO->setHasNoUnsignedWrap(true); + return BO; + } + static BinaryOperator *CreateNUWAdd(Value *V1, Value *V2, + const Twine &Name, Instruction *I) { + BinaryOperator *BO = CreateAdd(V1, V2, Name, I); + BO->setHasNoUnsignedWrap(true); + return BO; + } + /// CreateNSWSub - Create an Sub operator with the NSW flag set. /// static BinaryOperator *CreateNSWSub(Value *V1, Value *V2, @@ -235,6 +256,27 @@ return BO; } + /// CreateNUWSub - Create an Sub operator with the NUW flag set. + /// + static BinaryOperator *CreateNUWSub(Value *V1, Value *V2, + const Twine &Name = "") { + BinaryOperator *BO = CreateSub(V1, V2, Name); + BO->setHasNoUnsignedWrap(true); + return BO; + } + static BinaryOperator *CreateNUWSub(Value *V1, Value *V2, + const Twine &Name, BasicBlock *BB) { + BinaryOperator *BO = CreateSub(V1, V2, Name, BB); + BO->setHasNoUnsignedWrap(true); + return BO; + } + static BinaryOperator *CreateNUWSub(Value *V1, Value *V2, + const Twine &Name, Instruction *I) { + BinaryOperator *BO = CreateSub(V1, V2, Name, I); + BO->setHasNoUnsignedWrap(true); + return BO; + } + /// CreateExactSDiv - Create an SDiv operator with the exact flag set. /// static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2, From evan.cheng at apple.com Wed Nov 11 20:50:39 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Nov 2009 18:50:39 -0800 Subject: [llvm-commits] [llvm] r86404 - in /llvm/trunk/lib/Target/ARM: ARMAddressingModes.h ARMISelDAGToDAG.cpp ARMInstrInfo.td AsmPrinter/ARMAsmPrinter.cpp NEONPreAllocPass.cpp In-Reply-To: <07E25920-8744-4E1E-B020-292B6B32984A@apple.com> References: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> <90BAE2B3-491D-4D6F-BA26-4A9CD2E54B84@apple.com> <07E25920-8744-4E1E-B020-292B6B32984A@apple.com> Message-ID: <7906991F-4249-4BC1-A2DE-D2CD39932E0F@apple.com> On Nov 11, 2009, at 8:40 AM, Jim Grosbach wrote: > > On Nov 10, 2009, at 1:27 AM, Evan Cheng wrote: > >> >> On Nov 7, 2009, at 1:25 PM, Jim Grosbach wrote: >> >>> >>> >>> bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N, >>> SDValue &Addr, SDValue &Update, >>> - SDValue &Opc) { >>> + SDValue &Opc, SDValue &Align) { >>> Addr = N; >>> // Default to no writeback. >>> Update = CurDAG->getRegister(0, MVT::i32); >>> Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), MVT::i32); >>> + // Default to no alignment. >>> + Align = CurDAG->getTargetConstant(0, MVT::i32); >>> return true; >>> } >> >> Shouldn't we be able to transfer the alignment on the LoadSDNode / StoreSDNode to Align (capped at 64 / 128 for 64-bit / 128-bit memory operations)? > > Potentially. I'm concerned about stack objects in frames we don't dynamically align, however. That could result in aligned load/stores of objects w/o guaranteed alignment, and I wanted to avoid that. That shouldn't happen. The alignment field on LoadSDNode and StoreSDNode should not be considered optional. They are required. Dan, is that right? Evan > > I've been wondering about the best approach for that. We could do the alignment anyway and consider the additional dynamic alignment situations (VLAs and such) to be optimization opportunities. Or we could let the user specify alignment as an optional operand to the NEON builtins. That doesn't help with any auto-vectorizing stuff we may do, however. I tend to prefer the first option. What do you think? > > >> >> Evan >> >>> >>> @@ -1008,8 +1010,8 @@ >>> SDNode *N = Op.getNode(); >>> DebugLoc dl = N->getDebugLoc(); >>> >>> - SDValue MemAddr, MemUpdate, MemOpc; >>> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) >>> + SDValue MemAddr, MemUpdate, MemOpc, Align; >>> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) >>> return NULL; >>> >>> SDValue Chain = N->getOperand(0); >>> @@ -1034,10 +1036,10 @@ >>> >>> if (is64BitVector) { >>> unsigned Opc = DOpcodes[OpcodeIndex]; >>> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >>> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; >>> std::vector ResTys(NumVecs, VT); >>> ResTys.push_back(MVT::Other); >>> - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >>> + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); >>> } >>> >>> EVT RegVT = GetNEONSubregVT(VT); >>> @@ -1045,10 +1047,10 @@ >>> // Quad registers are directly supported for VLD2, >>> // loading 2 pairs of D regs. >>> unsigned Opc = QOpcodes0[OpcodeIndex]; >>> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >>> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; >>> std::vector ResTys(4, VT); >>> ResTys.push_back(MVT::Other); >>> - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >>> + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); >>> Chain = SDValue(VLd, 4); >>> >>> // Combine the even and odd subregs to produce the result. >>> @@ -1069,14 +1071,15 @@ >>> >>> // Load the even subregs. >>> unsigned Opc = QOpcodes0[OpcodeIndex]; >>> - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; >>> - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); >>> + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; >>> + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 5); >>> Chain = SDValue(VLdA, NumVecs+1); >>> >>> // Load the odd subregs. >>> Opc = QOpcodes1[OpcodeIndex]; >>> - const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, Chain }; >>> - SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); >>> + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, >>> + Align, Chain }; >>> + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 5); >>> Chain = SDValue(VLdB, NumVecs+1); >>> >>> // Combine the even and odd subregs to produce the result. >>> @@ -1096,8 +1099,8 @@ >>> SDNode *N = Op.getNode(); >>> DebugLoc dl = N->getDebugLoc(); >>> >>> - SDValue MemAddr, MemUpdate, MemOpc; >>> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) >>> + SDValue MemAddr, MemUpdate, MemOpc, Align; >>> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) >>> return NULL; >>> >>> SDValue Chain = N->getOperand(0); >>> @@ -1124,13 +1127,14 @@ >>> Ops.push_back(MemAddr); >>> Ops.push_back(MemUpdate); >>> Ops.push_back(MemOpc); >>> + Ops.push_back(Align); >>> >>> if (is64BitVector) { >>> unsigned Opc = DOpcodes[OpcodeIndex]; >>> for (unsigned Vec = 0; Vec < NumVecs; ++Vec) >>> Ops.push_back(N->getOperand(Vec+3)); >>> Ops.push_back(Chain); >>> - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+4); >>> + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+5); >>> } >>> >>> EVT RegVT = GetNEONSubregVT(VT); >>> @@ -1145,7 +1149,7 @@ >>> N->getOperand(Vec+3))); >>> } >>> Ops.push_back(Chain); >>> - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), 8); >>> + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), 9); >>> } >>> >>> // Otherwise, quad registers are stored with two separate instructions, >>> @@ -1161,18 +1165,18 @@ >>> Ops.push_back(Chain); >>> unsigned Opc = QOpcodes0[OpcodeIndex]; >>> SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), >>> - MVT::Other, Ops.data(), NumVecs+4); >>> + MVT::Other, Ops.data(), NumVecs+5); >>> Chain = SDValue(VStA, 1); >>> >>> // Store the odd subregs. >>> Ops[0] = SDValue(VStA, 0); // MemAddr >>> for (unsigned Vec = 0; Vec < NumVecs; ++Vec) >>> - Ops[Vec+3] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, >>> + Ops[Vec+4] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, >>> N->getOperand(Vec+3)); >>> - Ops[NumVecs+3] = Chain; >>> + Ops[NumVecs+4] = Chain; >>> Opc = QOpcodes1[OpcodeIndex]; >>> SDNode *VStB = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), >>> - MVT::Other, Ops.data(), NumVecs+4); >>> + MVT::Other, Ops.data(), NumVecs+5); >>> Chain = SDValue(VStB, 1); >>> ReplaceUses(SDValue(N, 0), Chain); >>> return NULL; >>> @@ -1186,8 +1190,8 @@ >>> SDNode *N = Op.getNode(); >>> DebugLoc dl = N->getDebugLoc(); >>> >>> - SDValue MemAddr, MemUpdate, MemOpc; >>> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) >>> + SDValue MemAddr, MemUpdate, MemOpc, Align; >>> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) >>> return NULL; >>> >>> SDValue Chain = N->getOperand(0); >>> @@ -1224,6 +1228,7 @@ >>> Ops.push_back(MemAddr); >>> Ops.push_back(MemUpdate); >>> Ops.push_back(MemOpc); >>> + Ops.push_back(Align); >>> >>> unsigned Opc = 0; >>> if (is64BitVector) { >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=86404&r1=86403&r2=86404&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sat Nov 7 15:25:39 2009 >>> @@ -340,9 +340,9 @@ >>> // addrmode6 := reg with optional writeback >>> // >>> def addrmode6 : Operand, >>> - ComplexPattern { >>> + ComplexPattern { >>> let PrintMethod = "printAddrMode6Operand"; >>> - let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm); >>> + let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm); >>> } >>> >>> // addrmodepc := pc + reg >>> >>> Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=86404&r1=86403&r2=86404&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Nov 7 15:25:39 2009 >>> @@ -638,9 +638,17 @@ >>> const MachineOperand &MO1 = MI->getOperand(Op); >>> const MachineOperand &MO2 = MI->getOperand(Op+1); >>> const MachineOperand &MO3 = MI->getOperand(Op+2); >>> + const MachineOperand &MO4 = MI->getOperand(Op+3); >>> >>> - // FIXME: No support yet for specifying alignment. >>> - O << "[" << getRegisterName(MO1.getReg()) << "]"; >>> + O << "[" << getRegisterName(MO1.getReg()); >>> + if (MO4.getImm()) { >>> + if (Subtarget->isTargetDarwin()) >>> + O << ", :"; >>> + else >>> + O << " @"; >>> + O << MO4.getImm(); >>> + } >>> + O << "]"; >>> >>> if (ARM_AM::getAM6WBFlag(MO3.getImm())) { >>> if (MO2.getReg() == 0) >>> >>> Modified: llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp?rev=86404&r1=86403&r2=86404&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Sat Nov 7 15:25:39 2009 >>> @@ -177,20 +177,20 @@ >>> case ARM::VST2LNd8: >>> case ARM::VST2LNd16: >>> case ARM::VST2LNd32: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 2; >>> return true; >>> >>> case ARM::VST2q8: >>> case ARM::VST2q16: >>> case ARM::VST2q32: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 4; >>> return true; >>> >>> case ARM::VST2LNq16a: >>> case ARM::VST2LNq32a: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 2; >>> Offset = 0; >>> Stride = 2; >>> @@ -198,7 +198,7 @@ >>> >>> case ARM::VST2LNq16b: >>> case ARM::VST2LNq32b: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 2; >>> Offset = 1; >>> Stride = 2; >>> @@ -211,14 +211,14 @@ >>> case ARM::VST3LNd8: >>> case ARM::VST3LNd16: >>> case ARM::VST3LNd32: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 3; >>> return true; >>> >>> case ARM::VST3q8a: >>> case ARM::VST3q16a: >>> case ARM::VST3q32a: >>> - FirstOpnd = 4; >>> + FirstOpnd = 5; >>> NumRegs = 3; >>> Offset = 0; >>> Stride = 2; >>> @@ -227,7 +227,7 @@ >>> case ARM::VST3q8b: >>> case ARM::VST3q16b: >>> case ARM::VST3q32b: >>> - FirstOpnd = 4; >>> + FirstOpnd = 5; >>> NumRegs = 3; >>> Offset = 1; >>> Stride = 2; >>> @@ -235,7 +235,7 @@ >>> >>> case ARM::VST3LNq16a: >>> case ARM::VST3LNq32a: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 3; >>> Offset = 0; >>> Stride = 2; >>> @@ -243,7 +243,7 @@ >>> >>> case ARM::VST3LNq16b: >>> case ARM::VST3LNq32b: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 3; >>> Offset = 1; >>> Stride = 2; >>> @@ -256,14 +256,14 @@ >>> case ARM::VST4LNd8: >>> case ARM::VST4LNd16: >>> case ARM::VST4LNd32: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 4; >>> return true; >>> >>> case ARM::VST4q8a: >>> case ARM::VST4q16a: >>> case ARM::VST4q32a: >>> - FirstOpnd = 4; >>> + FirstOpnd = 5; >>> NumRegs = 4; >>> Offset = 0; >>> Stride = 2; >>> @@ -272,7 +272,7 @@ >>> case ARM::VST4q8b: >>> case ARM::VST4q16b: >>> case ARM::VST4q32b: >>> - FirstOpnd = 4; >>> + FirstOpnd = 5; >>> NumRegs = 4; >>> Offset = 1; >>> Stride = 2; >>> @@ -280,7 +280,7 @@ >>> >>> case ARM::VST4LNq16a: >>> case ARM::VST4LNq32a: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 4; >>> Offset = 0; >>> Stride = 2; >>> @@ -288,7 +288,7 @@ >>> >>> case ARM::VST4LNq16b: >>> case ARM::VST4LNq32b: >>> - FirstOpnd = 3; >>> + FirstOpnd = 4; >>> NumRegs = 4; >>> Offset = 1; >>> Stride = 2; >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From arplynn at gmail.com Wed Nov 11 20:52:17 2009 From: arplynn at gmail.com (Alastair Lynn) Date: Thu, 12 Nov 2009 02:52:17 +0000 Subject: [llvm-commits] Second attempt at overflow intrinsics instcombine Message-ID: <60A28353-B33B-4CED-B510-22BAAF5C6560@gmail.com> Hello- Second time lucky. -------------- next part -------------- A non-text attachment was scrubbed... Name: overflow-instcombine.patch Type: application/octet-stream Size: 6822 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/87268409/attachment.obj From daniel at zuster.org Wed Nov 11 20:52:57 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 02:52:57 -0000 Subject: [llvm-commits] [llvm] r86933 - /llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Message-ID: <200911120252.nAC2qvVj018930@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Nov 11 20:52:56 2009 New Revision: 86933 URL: http://llvm.org/viewvc/llvm-project?rev=86933&view=rev Log: Add the braces gcc suggested. Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=86933&r1=86932&r2=86933&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Wed Nov 11 20:52:56 2009 @@ -434,33 +434,36 @@ // Skip over all PHI nodes, remembering them for later. BasicBlock::const_iterator OldI = BI->begin(); for (; (PN = dyn_cast(I)); ++I, ++OldI) { - if (I->hasMetadata()) + if (I->hasMetadata()) { if (TheCallMD) { if (MDNode *IMD = Context.getMetadata().getMD(DbgKind, I)) { MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD, Context); Context.getMetadata().addMD(DbgKind, NewMD, I); } - } else + } else { // The cloned instruction has dbg info but the call instruction // does not have dbg info. Remove dbg info from cloned instruction. Context.getMetadata().removeMD(DbgKind, I); + } + } PHIToResolve.push_back(cast(OldI)); } } // Otherwise, remap the rest of the instructions normally. for (; I != NewBB->end(); ++I) { - if (I->hasMetadata()) + if (I->hasMetadata()) { if (TheCallMD) { if (MDNode *IMD = Context.getMetadata().getMD(DbgKind, I)) { MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD, Context); Context.getMetadata().addMD(DbgKind, NewMD, I); } - } else + } else { // The cloned instruction has dbg info but the call instruction // does not have dbg info. Remove dbg info from cloned instruction. Context.getMetadata().removeMD(DbgKind, I); - + } + } RemapInstruction(I, ValueMap); } } From echristo at apple.com Wed Nov 11 21:12:19 2009 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Nov 2009 03:12:19 -0000 Subject: [llvm-commits] [llvm] r86941 - in /llvm/trunk: lib/ExecutionEngine/JIT/JITEmitter.cpp unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> Author: echristo Date: Wed Nov 11 21:12:18 2009 New Revision: 86941 URL: http://llvm.org/viewvc/llvm-project?rev=86941&view=rev Log: Use stubs when we have them, otherwise use code we already have, otherwise create a stub. Add a test to make sure we don't create extraneous stubs. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86941&r1=86940&r2=86941&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Wed Nov 11 21:12:18 2009 @@ -225,7 +225,7 @@ assert(TheJITResolver == 0 && "Multiple JIT resolvers?"); TheJITResolver = this; } - + ~JITResolver() { TheJITResolver = 0; } @@ -256,10 +256,10 @@ state.AddCallSite(locked, Location, F); return (void*)(intptr_t)LazyResolverFn; } - + void getRelocatableGVs(SmallVectorImpl &GVs, SmallVectorImpl &Ptrs); - + GlobalValue *invalidateStub(void *Stub); /// getGOTIndexForAddress - Return a new or existing index in the GOT for @@ -291,7 +291,7 @@ /// Relocations - These are the relocations that the function needs, as /// emitted. std::vector Relocations; - + /// MBBLocations - This vector is a mapping from MBB ID's to their address. /// It is filled in by the StartMachineBasicBlock callback and queried by /// the getMachineBasicBlockAddress callback. @@ -312,7 +312,7 @@ /// JumpTable - The jump tables for the current function. /// MachineJumpTableInfo *JumpTable; - + /// JumpTableBase - A pointer to the first entry in the jump table. /// void *JumpTableBase; @@ -326,7 +326,7 @@ /// DR - The debug registerer for the jit. OwningPtr DR; - /// LabelLocations - This vector is a mapping from Label ID's to their + /// LabelLocations - This vector is a mapping from Label ID's to their /// address. std::vector LabelLocations; @@ -336,7 +336,7 @@ // GVSet - a set to keep track of which globals have been seen SmallPtrSet GVSet; - // CurFn - The llvm function being emitted. Only valid during + // CurFn - The llvm function being emitted. Only valid during // finishFunction(). const Function *CurFn; @@ -368,7 +368,7 @@ // reference the stub. When the count of a stub's references drops to zero, // the stub is unused. DenseMap > StubFnRefs; - + DebugLocTuple PrevDLT; public: @@ -388,7 +388,7 @@ DR.reset(new JITDebugRegisterer(TM)); } } - ~JITEmitter() { + ~JITEmitter() { delete MemMgr; } @@ -397,16 +397,16 @@ /// static inline bool classof(const JITEmitter*) { return true; } static inline bool classof(const MachineCodeEmitter*) { return true; } - + JITResolver &getJITResolver() { return Resolver; } virtual void startFunction(MachineFunction &F); virtual bool finishFunction(MachineFunction &F); - + void emitConstantPool(MachineConstantPool *MCP); void initJumpTableInfo(MachineJumpTableInfo *MJTI); void emitJumpTableInfo(MachineJumpTableInfo *MJTI); - + virtual void startGVStub(const GlobalValue* GV, unsigned StubSize, unsigned Alignment = 1); virtual void startGVStub(const GlobalValue* GV, void *Buffer, @@ -425,7 +425,7 @@ virtual void addRelocation(const MachineRelocation &MR) { Relocations.push_back(MR); } - + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { if (MBBLocations.size() <= (unsigned)MBB->getNumber()) MBBLocations.resize((MBB->getNumber()+1)*2); @@ -438,7 +438,7 @@ virtual uintptr_t getJumpTableEntryAddress(unsigned Entry) const; virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { - assert(MBBLocations.size() > (unsigned)MBB->getNumber() && + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && MBBLocations[MBB->getNumber()] && "MBB not emitted!"); return MBBLocations[MBB->getNumber()]; } @@ -456,7 +456,7 @@ /// using the stub at the specified address. Allows /// deallocateMemForFunction to also remove stubs no longer referenced. void AddStubToCurrentFunction(void *Stub); - + virtual void processDebugLoc(DebugLoc DL, bool BeforePrintingInsn); virtual void emitLabel(uint64_t LabelID) { @@ -466,11 +466,11 @@ } virtual uintptr_t getLabelAddress(uint64_t LabelID) const { - assert(LabelLocations.size() > (unsigned)LabelID && + assert(LabelLocations.size() > (unsigned)LabelID && LabelLocations[LabelID] && "Label not emitted!"); return LabelLocations[LabelID]; } - + virtual void setModuleInfo(MachineModuleInfo* Info) { MMI = Info; if (DE.get()) DE->setModuleInfo(Info); @@ -479,7 +479,7 @@ void setMemoryExecutable() { MemMgr->setMemoryExecutable(); } - + JITMemoryManager *getMemMgr() const { return MemMgr; } private: @@ -573,7 +573,7 @@ IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, GVAddress, JE); - DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym + DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym << "] for GV '" << GV->getName() << "'\n"); return IndirectSym; @@ -607,10 +607,10 @@ void JITResolver::getRelocatableGVs(SmallVectorImpl &GVs, SmallVectorImpl &Ptrs) { MutexGuard locked(TheJIT->lock); - + const FunctionToStubMapTy &FM = state.getFunctionToStubMap(locked); GlobalToIndirectSymMapTy &GM = state.getGlobalToIndirectSymMap(locked); - + for (FunctionToStubMapTy::const_iterator i = FM.begin(), e = FM.end(); i != e; ++i){ Function *F = i->first; @@ -646,7 +646,7 @@ GM.erase(i); return GV; } - + // Lastly, check to see if it's in the ExternalFnToStubMap. for (std::map::iterator i = ExternalFnToStubMap.begin(), e = ExternalFnToStubMap.end(); i != e; ++i) { @@ -655,7 +655,7 @@ ExternalFnToStubMap.erase(i); break; } - + return 0; } @@ -664,7 +664,7 @@ /// it if necessary, then returns the resultant function pointer. void *JITResolver::JITCompilerFn(void *Stub) { JITResolver &JR = *TheJITResolver; - + Function* F = 0; void* ActualPtr = 0; @@ -684,16 +684,16 @@ // If we have already code generated the function, just return the address. void *Result = TheJIT->getPointerToGlobalIfAvailable(F); - + if (!Result) { // Otherwise we don't have it, do lazy compilation now. - + // If lazy compilation is disabled, emit a useful error message and abort. if (!TheJIT->isCompilingLazily()) { llvm_report_error("LLVM JIT requested to do lazy compilation of function '" + F->getName() + "' when lazy compiles are disabled!"); } - + DEBUG(errs() << "JIT: Lazily resolving function '" << F->getName() << "' In stub ptr = " << Stub << " actual ptr = " << ActualPtr << "\n"); @@ -736,15 +736,18 @@ // If we have already compiled the function, return a pointer to its body. Function *F = cast(V); - void *ResultPtr; - if (MayNeedFarStub) { - // Return the function stub if it's already created. - ResultPtr = Resolver.getFunctionStubIfAvailable(F); - if (ResultPtr) - AddStubToCurrentFunction(ResultPtr); - } else { - ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); + + void *FnStub = Resolver.getFunctionStubIfAvailable(F); + if (FnStub) { + // Return the function stub if it's already created. We do this first + // so that we're returning the same address for the function as any + // previous call. + AddStubToCurrentFunction(FnStub); + return FnStub; } + + // Otherwise if we have code, go ahead and return that. + void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); if (ResultPtr) return ResultPtr; // If this is an external function pointer, we can force the JIT to @@ -778,11 +781,11 @@ // resolved address. void *GVAddress = getPointerToGlobal(V, Reference, false); void *StubAddr = Resolver.getGlobalValueIndirectSym(V, GVAddress); - + // Add the stub to the current function's list of referenced stubs, so we can // deallocate them if the current function is ever freed. AddStubToCurrentFunction(StubAddr); - + return StubAddr; } @@ -807,7 +810,7 @@ NextLine.Loc = DL; EmissionDetails.LineStarts.push_back(NextLine); } - + PrevDLT = CurDLT; } } @@ -832,7 +835,7 @@ static unsigned GetJumpTableSizeInBytes(MachineJumpTableInfo *MJTI) { const std::vector &JT = MJTI->getJumpTables(); if (JT.empty()) return 0; - + unsigned NumEntries = 0; for (unsigned i = 0, e = JT.size(); i != e; ++i) NumEntries += JT[i].MBBs.size(); @@ -844,7 +847,7 @@ static uintptr_t RoundUpToAlign(uintptr_t Size, unsigned Alignment) { if (Alignment == 0) Alignment = 1; - // Since we do not know where the buffer will be allocated, be pessimistic. + // Since we do not know where the buffer will be allocated, be pessimistic. return Size + Alignment; } @@ -854,7 +857,7 @@ unsigned JITEmitter::addSizeOfGlobal(const GlobalVariable *GV, unsigned Size) { const Type *ElTy = GV->getType()->getElementType(); size_t GVSize = (size_t)TheJIT->getTargetData()->getTypeAllocSize(ElTy); - size_t GVAlign = + size_t GVAlign = (size_t)TheJIT->getTargetData()->getPreferredAlignment(GV); DEBUG(errs() << "JIT: Adding in size " << GVSize << " alignment " << GVAlign); DEBUG(GV->dump()); @@ -871,7 +874,7 @@ /// but are referenced from the constant; put them in GVSet and add their /// size into the running total Size. -unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C, +unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C, unsigned Size) { // If its undefined, return the garbage. if (isa(C)) @@ -934,7 +937,7 @@ /// addSizeOfGLobalsInInitializer - handle any globals that we haven't seen yet /// but are referenced from the given initializer. -unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant *Init, +unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant *Init, unsigned Size) { if (!isa(Init) && !isa(Init) && @@ -955,7 +958,7 @@ unsigned Size = 0; GVSet.clear(); - for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); + for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); MBB != E; ++MBB) { for (MachineBasicBlock::const_iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { @@ -987,7 +990,7 @@ DEBUG(errs() << "JIT: About to look through initializers\n"); // Look for more globals that are referenced only from initializers. // GVSet.end is computed each time because the set can grow as we go. - for (SmallPtrSet::iterator I = GVSet.begin(); + for (SmallPtrSet::iterator I = GVSet.begin(); I != GVSet.end(); I++) { const GlobalVariable* GV = *I; if (GV->hasInitializer()) @@ -1009,10 +1012,10 @@ const TargetInstrInfo* TII = F.getTarget().getInstrInfo(); MachineJumpTableInfo *MJTI = F.getJumpTableInfo(); MachineConstantPool *MCP = F.getConstantPool(); - + // Ensure the constant pool/jump table info is at least 4-byte aligned. ActualSize = RoundUpToAlign(ActualSize, 16); - + // Add the alignment of the constant pool ActualSize = RoundUpToAlign(ActualSize, MCP->getConstantPoolAlignment()); @@ -1024,7 +1027,7 @@ // Add the jump table size ActualSize += GetJumpTableSizeInBytes(MJTI); - + // Add the alignment for the function ActualSize = RoundUpToAlign(ActualSize, std::max(F.getFunction()->getAlignment(), 8U)); @@ -1097,7 +1100,7 @@ ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol(), false); DEBUG(errs() << "JIT: Map \'" << MR.getExternalSymbol() << "\' to [" - << ResultPtr << "]\n"); + << ResultPtr << "]\n"); // If the target REALLY wants a stub for this function, emit it now. if (MR.mayNeedFarStub()) { @@ -1255,7 +1258,7 @@ if (MMI) MMI->EndFunction(); - + return false; } @@ -1293,20 +1296,20 @@ // If the function did not reference any stubs, return. if (CurFnStubUses.find(F) == CurFnStubUses.end()) return; - + // For each referenced stub, erase the reference to this function, and then // erase the list of referenced stubs. SmallVectorImpl &StubList = CurFnStubUses[F]; for (unsigned i = 0, e = StubList.size(); i != e; ++i) { void *Stub = StubList[i]; - + // If we already invalidated this stub for this function, continue. if (StubFnRefs.count(Stub) == 0) continue; - + SmallPtrSet &FnRefs = StubFnRefs[Stub]; FnRefs.erase(F); - + // If this function was the last reference to the stub, invalidate the stub // in the JITResolver. Were there a memory manager deallocateStub routine, // we could call that at this point too. @@ -1389,7 +1392,7 @@ const std::vector &JT = MJTI->getJumpTables(); if (JT.empty()) return; - + unsigned NumEntries = 0; for (unsigned i = 0, e = JT.size(); i != e; ++i) NumEntries += JT[i].MBBs.size(); @@ -1409,7 +1412,7 @@ const std::vector &JT = MJTI->getJumpTables(); if (JT.empty() || JumpTableBase == 0) return; - + if (TargetMachine::getRelocationModel() == Reloc::PIC_) { assert(MJTI->getEntrySize() == 4 && "Cross JIT'ing?"); // For each jump table, place the offset from the beginning of the table @@ -1428,8 +1431,8 @@ } } else { assert(MJTI->getEntrySize() == sizeof(void*) && "Cross JIT'ing?"); - - // For each jump table, map each target in the jump table to the address of + + // For each jump table, map each target in the jump table to the address of // an emitted MachineBasicBlock. intptr_t *SlotPtr = (intptr_t*)JumpTableBase; @@ -1448,7 +1451,7 @@ SavedBufferBegin = BufferBegin; SavedBufferEnd = BufferEnd; SavedCurBufferPtr = CurBufferPtr; - + BufferBegin = CurBufferPtr = MemMgr->allocateStub(GV, StubSize, Alignment); BufferEnd = BufferBegin+StubSize+1; } @@ -1458,7 +1461,7 @@ SavedBufferBegin = BufferBegin; SavedBufferEnd = BufferEnd; SavedCurBufferPtr = CurBufferPtr; - + BufferBegin = CurBufferPtr = (uint8_t *)Buffer; BufferEnd = BufferBegin+StubSize+1; } @@ -1487,15 +1490,15 @@ uintptr_t JITEmitter::getJumpTableEntryAddress(unsigned Index) const { const std::vector &JT = JumpTable->getJumpTables(); assert(Index < JT.size() && "Invalid jump table index!"); - + unsigned Offset = 0; unsigned EntrySize = JumpTable->getEntrySize(); - + for (unsigned i = 0; i < Index; ++i) Offset += JT[i].MBBs.size(); - + Offset *= EntrySize; - + return (uintptr_t)((char *)JumpTableBase + Offset); } @@ -1540,7 +1543,7 @@ // If we have already code generated the function, just return the address. if (void *Addr = getPointerToGlobalIfAvailable(F)) return Addr; - + // Get a stub if the target supports it. assert(isa(JCE) && "Unexpected MCE?"); JITEmitter *JE = cast(getCodeEmitter()); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=86941&r1=86940&r2=86941&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Wed Nov 11 21:12:18 2009 @@ -61,6 +61,7 @@ public: RecordingJITMemoryManager() : Base(JITMemoryManager::CreateDefaultMemManager()) { + stubsAllocated = 0; } virtual void setMemoryWritable() { Base->setMemoryWritable(); } @@ -88,8 +89,10 @@ StartFunctionBodyCall(Result, F, InitialActualSize, ActualSize)); return Result; } + int stubsAllocated; virtual uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize, unsigned Alignment) { + stubsAllocated++; return Base->allocateStub(F, StubSize, Alignment); } struct EndFunctionBodyCall { @@ -455,6 +458,44 @@ NumTablesDeallocated); } +typedef int (*FooPtr) (); + +TEST_F(JITTest, NoStubs) { + LoadAssembly("define void @bar() {" + "entry: " + "ret void" + "}" + " " + "define i32 @foo() {" + "entry:" + "call void @bar()" + "ret i32 undef" + "}" + " " + "define i32 @main() {" + "entry:" + "%0 = call i32 @foo()" + "call void @bar()" + "ret i32 undef" + "}"); + Function *foo = M->getFunction("foo"); + uintptr_t tmp = (uintptr_t)(TheJIT->getPointerToFunction(foo)); + FooPtr ptr = (FooPtr)(tmp); + + (ptr)(); + + // We should now allocate no more stubs, we have the code to foo + // and the existing stub for bar. + int stubsBefore = RJMM->stubsAllocated; + Function *func = M->getFunction("main"); + TheJIT->getPointerToFunction(func); + + Function *bar = M->getFunction("bar"); + TheJIT->getPointerToFunction(bar); + + ASSERT_EQ(stubsBefore, RJMM->stubsAllocated); +} + // This code is copied from JITEventListenerTest, but it only runs once for all // the tests in this directory. Everything seems fine, but that's strange // behavior. From echristo at apple.com Wed Nov 11 21:13:17 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 11 Nov 2009 19:13:17 -0800 Subject: [llvm-commits] [llvm] r86941 - in /llvm/trunk: lib/ExecutionEngine/JIT/JITEmitter.cpp unittests/ExecutionEngine/JIT/JITTest.cpp In-Reply-To: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> References: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> Message-ID: <71696410-CFB0-4A50-BCE2-5F6CCA9938E8@apple.com> On Nov 11, 2009, at 7:12 PM, Eric Christopher wrote: > Author: echristo > Date: Wed Nov 11 21:12:18 2009 > New Revision: 86941 > > URL: http://llvm.org/viewvc/llvm-project?rev=86941&view=rev > Log: > Use stubs when we have them, otherwise use code we already have, > otherwise create a stub. > > Add a test to make sure we don't create extraneous stubs. And, dammit, a bunch of whitespace changes. I thought I fixed those earlier. Apologies. -eric From arplynn at gmail.com Wed Nov 11 21:23:36 2009 From: arplynn at gmail.com (Alastair Lynn) Date: Thu, 12 Nov 2009 03:23:36 +0000 Subject: [llvm-commits] Overflow intrinsics patch Message-ID: <17C1443D-34E2-4FE9-BBF9-13BECDA37A51@gmail.com> Hello- Third time lucky, here is the absolutely bug-free patch. -------------- next part -------------- A non-text attachment was scrubbed... Name: overflow-instcombine.patch Type: application/octet-stream Size: 6748 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/1c4104c4/attachment.obj From grosbach at apple.com Wed Nov 11 21:28:35 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 Nov 2009 03:28:35 -0000 Subject: [llvm-commits] [llvm] r86945 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911120328.nAC3SZdI020226@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 11 21:28:35 2009 New Revision: 86945 URL: http://llvm.org/viewvc/llvm-project?rev=86945&view=rev Log: Revert 86857. It's causing consumer-typeset to fail, and there's a better way to do it forthcoming anyway. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86945&r1=86944&r2=86945&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Wed Nov 11 21:28:35 2009 @@ -294,11 +294,6 @@ // sizes of each block, the location of all the water, and finding all of the // constant pool users. InitialFunctionScan(MF, CPEMIs); - - bool MadeChange = false; - if (isThumb2) - MadeChange |= OptimizeThumb2JumpTables(MF); - CPEMIs.clear(); /// Remove dead constant pool entries. @@ -306,6 +301,7 @@ // Iteratively place constant pool entries and fix up branches until there // is no change. + bool MadeChange = false; unsigned NoCPIters = 0, NoBRIters = 0; while (true) { bool CPChange = false; @@ -1480,6 +1476,7 @@ } MadeChange |= OptimizeThumb2Branches(MF); + MadeChange |= OptimizeThumb2JumpTables(MF); return MadeChange; } @@ -1725,8 +1722,8 @@ JTBB->addSuccessor(NewBB); // Update internal data structures to account for the newly inserted MBB. - // Don't mark the new block as having water following it, as we want the - // blocks following the jump table to be as close together as possible. + // This is almost the same as UpdateForInsertedWaterBlock, except that + // the Water goes after OrigBB, not NewBB. MF.RenumberBlocks(NewBB); // Insert a size into BBSizes to align it properly with the (newly From grosbach at apple.com Wed Nov 11 21:55:34 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 Nov 2009 03:55:34 -0000 Subject: [llvm-commits] [llvm] r86947 - in /llvm/trunk: include/llvm/CodeGen/MachineBasicBlock.h lib/CodeGen/CodePlacementOpt.cpp lib/CodeGen/MachineBasicBlock.cpp Message-ID: <200911120355.nAC3tY4u020978@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 11 21:55:33 2009 New Revision: 86947 URL: http://llvm.org/viewvc/llvm-project?rev=86947&view=rev Log: Move the utility function UpdateTerminator() from CodePlacementOpt() into MachineBasicBlock so other passes can utilize it. Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=86947&r1=86946&r2=86947&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Wed Nov 11 21:55:33 2009 @@ -225,7 +225,13 @@ /// potential fall-throughs at the end of the block. void moveBefore(MachineBasicBlock *NewAfter); void moveAfter(MachineBasicBlock *NewBefore); - + + /// updateTerminator - Update the terminator instructions in block to account + /// for changes to the layout. If the block previously used a fallthrough, + /// it may now need a branch, and if it previously used branching it may now + /// be able to use a fallthrough. + void updateTerminator(); + // Machine-CFG mutators /// addSuccessor - Add succ as a successor of this MachineBasicBlock. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=86947&r1=86946&r2=86947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Wed Nov 11 21:55:33 2009 @@ -56,7 +56,6 @@ MachineFunction::iterator InsertPt, MachineFunction::iterator Begin, MachineFunction::iterator End); - void UpdateTerminator(MachineBasicBlock *MBB); bool EliminateUnconditionalJumpsToTop(MachineFunction &MF, MachineLoop *L); bool MoveDiscontiguousLoopBlocks(MachineFunction &MF, @@ -141,66 +140,9 @@ MF.splice(InsertPt, Begin, End); - UpdateTerminator(prior(Begin)); - UpdateTerminator(OldBeginPrior); - UpdateTerminator(OldEndPrior); -} - -/// UpdateTerminator - Update the terminator instructions in MBB to account -/// for changes to the layout. If the block previously used a fallthrough, -/// it may now need a branch, and if it previously used branching it may now -/// be able to use a fallthrough. -/// -void CodePlacementOpt::UpdateTerminator(MachineBasicBlock *MBB) { - // A block with no successors has no concerns with fall-through edges. - if (MBB->succ_empty()) return; - - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); - (void) B; - assert(!B && "UpdateTerminators requires analyzable predecessors!"); - if (Cond.empty()) { - if (TBB) { - // The block has an unconditional branch. If its successor is now - // its layout successor, delete the branch. - if (MBB->isLayoutSuccessor(TBB)) - TII->RemoveBranch(*MBB); - } else { - // The block has an unconditional fallthrough. If its successor is not - // its layout successor, insert a branch. - TBB = *MBB->succ_begin(); - if (!MBB->isLayoutSuccessor(TBB)) - TII->InsertBranch(*MBB, TBB, 0, Cond); - } - } else { - if (FBB) { - // The block has a non-fallthrough conditional branch. If one of its - // successors is its layout successor, rewrite it to a fallthrough - // conditional branch. - if (MBB->isLayoutSuccessor(TBB)) { - TII->RemoveBranch(*MBB); - TII->ReverseBranchCondition(Cond); - TII->InsertBranch(*MBB, FBB, 0, Cond); - } else if (MBB->isLayoutSuccessor(FBB)) { - TII->RemoveBranch(*MBB); - TII->InsertBranch(*MBB, TBB, 0, Cond); - } - } else { - // The block has a fallthrough conditional branch. - MachineBasicBlock *MBBA = *MBB->succ_begin(); - MachineBasicBlock *MBBB = *next(MBB->succ_begin()); - if (MBBA == TBB) std::swap(MBBB, MBBA); - if (MBB->isLayoutSuccessor(TBB)) { - TII->RemoveBranch(*MBB); - TII->ReverseBranchCondition(Cond); - TII->InsertBranch(*MBB, MBBA, 0, Cond); - } else if (!MBB->isLayoutSuccessor(MBBA)) { - TII->RemoveBranch(*MBB); - TII->InsertBranch(*MBB, TBB, MBBA, Cond); - } - } - } + prior(Begin)->updateTerminator(); + OldBeginPrior->updateTerminator(); + OldEndPrior->updateTerminator(); } /// EliminateUnconditionalJumpsToTop - Move blocks which unconditionally jump Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=86947&r1=86946&r2=86947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Nov 11 21:55:33 2009 @@ -17,6 +17,7 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrDesc.h" +#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/raw_ostream.h" @@ -242,6 +243,58 @@ getParent()->splice(++BBI, this); } +void MachineBasicBlock::updateTerminator() { + const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo(); + // A block with no successors has no concerns with fall-through edges. + if (this->succ_empty()) return; + + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + bool B = TII->AnalyzeBranch(*this, TBB, FBB, Cond); + (void) B; + assert(!B && "UpdateTerminators requires analyzable predecessors!"); + if (Cond.empty()) { + if (TBB) { + // The block has an unconditional branch. If its successor is now + // its layout successor, delete the branch. + if (isLayoutSuccessor(TBB)) + TII->RemoveBranch(*this); + } else { + // The block has an unconditional fallthrough. If its successor is not + // its layout successor, insert a branch. + TBB = *succ_begin(); + if (!isLayoutSuccessor(TBB)) + TII->InsertBranch(*this, TBB, 0, Cond); + } + } else { + if (FBB) { + // The block has a non-fallthrough conditional branch. If one of its + // successors is its layout successor, rewrite it to a fallthrough + // conditional branch. + if (isLayoutSuccessor(TBB)) { + TII->RemoveBranch(*this); + TII->ReverseBranchCondition(Cond); + TII->InsertBranch(*this, FBB, 0, Cond); + } else if (isLayoutSuccessor(FBB)) { + TII->RemoveBranch(*this); + TII->InsertBranch(*this, TBB, 0, Cond); + } + } else { + // The block has a fallthrough conditional branch. + MachineBasicBlock *MBBA = *succ_begin(); + MachineBasicBlock *MBBB = *next(succ_begin()); + if (MBBA == TBB) std::swap(MBBB, MBBA); + if (isLayoutSuccessor(TBB)) { + TII->RemoveBranch(*this); + TII->ReverseBranchCondition(Cond); + TII->InsertBranch(*this, MBBA, 0, Cond); + } else if (!isLayoutSuccessor(MBBA)) { + TII->RemoveBranch(*this); + TII->InsertBranch(*this, TBB, MBBA, Cond); + } + } + } +} void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ) { Successors.push_back(succ); From sabre at nondot.org Wed Nov 11 22:36:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 04:36:58 -0000 Subject: [llvm-commits] [llvm] r86950 - in /llvm/trunk: include/llvm/Analysis/LazyValueInfo.h lib/Analysis/LazyValueInfo.cpp Message-ID: <200911120436.nAC4axdQ022329@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 22:36:58 2009 New Revision: 86950 URL: http://llvm.org/viewvc/llvm-project?rev=86950&view=rev Log: Add a new getPredicateOnEdge method which returns more rich information for constant constraints. Improve the LVI lattice to include inequality constraints. Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyValueInfo.h?rev=86950&r1=86949&r2=86950&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h Wed Nov 11 22:36:58 2009 @@ -31,19 +31,21 @@ static char ID; LazyValueInfo() : FunctionPass(&ID), PImpl(0) {} - /// Tristate - This is used to return yes/no/dunno results. + /// Tristate - This is used to return true/false/dunno results. enum Tristate { - Unknown = -1, No = 0, Yes = 1 + Unknown = -1, False = 0, True = 1 }; // Public query interface. + /// getPredicateOnEdge - Determine whether the specified value comparison + /// with a constant is known to be true or false on the specified CFG edge. + /// Pred is a CmpInst predicate. + Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C, + BasicBlock *FromBB, BasicBlock *ToBB); + - /// isEqual - Determine whether the specified value is known to be equal or - /// not-equal to the specified constant at the end of the specified block. - Tristate isEqual(Value *V, Constant *C, BasicBlock *BB); - /// getConstant - Determine whether the specified value is known to be a /// constant at the end of the specified block. Return null if not. Constant *getConstant(Value *V, BasicBlock *BB); Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86950&r1=86949&r2=86950&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 22:36:58 2009 @@ -51,13 +51,17 @@ undefined, /// constant - This LLVM Value has a specific constant value. constant, + + /// notconstant - This LLVM value is known to not have the specified value. + notconstant, + /// overdefined - This instruction is not known to be constant, and we know /// it has a value. overdefined }; /// Val: This stores the current lattice value along with the Constant* for - /// the constant if this is a 'constant' value. + /// the constant if this is a 'constant' or 'notconstant' value. PointerIntPair Val; public: @@ -68,9 +72,15 @@ Res.markConstant(C); return Res; } + static LVILatticeVal getNot(Constant *C) { + LVILatticeVal Res; + Res.markNotConstant(C); + return Res; + } bool isUndefined() const { return Val.getInt() == undefined; } bool isConstant() const { return Val.getInt() == constant; } + bool isNotConstant() const { return Val.getInt() == notconstant; } bool isOverdefined() const { return Val.getInt() == overdefined; } Constant *getConstant() const { @@ -78,12 +88,9 @@ return Val.getPointer(); } - /// getConstantInt - If this is a constant with a ConstantInt value, return it - /// otherwise return null. - ConstantInt *getConstantInt() const { - if (isConstant()) - return dyn_cast(getConstant()); - return 0; + Constant *getNotConstant() const { + assert(isNotConstant() && "Cannot get the constant of a non-notconstant!"); + return Val.getPointer(); } /// markOverdefined - Return true if this is a change in status. @@ -108,12 +115,41 @@ return true; } + /// markNotConstant - Return true if this is a change in status. + bool markNotConstant(Constant *V) { + if (isNotConstant()) { + assert(getNotConstant() == V && "Marking !constant with different value"); + return false; + } + + if (isConstant()) + assert(getConstant() != V && "Marking not constant with different value"); + else + assert(isUndefined()); + + Val.setInt(notconstant); + assert(V && "Marking constant with NULL"); + Val.setPointer(V); + return true; + } + /// mergeIn - Merge the specified lattice value into this one, updating this /// one and returning true if anything changed. bool mergeIn(const LVILatticeVal &RHS) { if (RHS.isUndefined() || isOverdefined()) return false; if (RHS.isOverdefined()) return markOverdefined(); + if (RHS.isNotConstant()) { + if (isNotConstant()) { + if (getNotConstant() != RHS.getNotConstant()) + return markOverdefined(); + return false; + } + if (isConstant() && getConstant() != RHS.getNotConstant()) + return markOverdefined(); + return markNotConstant(RHS.getNotConstant()); + } + // RHS must be a constant, we must be undef or constant. if (isConstant() && getConstant() != RHS.getConstant()) return markOverdefined(); @@ -130,6 +166,9 @@ return OS << "undefined"; if (Val.isOverdefined()) return OS << "overdefined"; + + if (Val.isNotConstant()) + return OS << "notconstant<" << *Val.getNotConstant() << '>'; return OS << "constant<" << *Val.getConstant() << '>'; } } @@ -181,6 +220,7 @@ // false SETNE. if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) return LVILatticeVal::get(cast(ICI->getOperand(1))); + return LVILatticeVal::getNot(cast(ICI->getOperand(1))); } } } @@ -291,22 +331,50 @@ return 0; } -/// isEqual - Determine whether the specified value is known to be equal or -/// not-equal to the specified constant at the end of the specified block. +/// getPredicateOnEdge - Determine whether the specified value comparison +/// with a constant is known to be true or false on the specified CFG edge. +/// Pred is a CmpInst predicate. LazyValueInfo::Tristate -LazyValueInfo::isEqual(Value *V, Constant *C, BasicBlock *BB) { +LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C, + BasicBlock *FromBB, BasicBlock *ToBB) { + LVILatticeVal Result; + // If already a constant, we can use constant folding. if (Constant *VC = dyn_cast(V)) { - // Ignore FP for now. TODO, consider what form of equality we want. - if (C->getType()->isFPOrFPVector()) - return Unknown; + Result = LVILatticeVal::get(VC); + } else { + DenseMap BlockValues; - Constant *Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, VC,C,TD); - if (ConstantInt *ResCI = dyn_cast(Res)) - return ResCI->isZero() ? No : Yes; + DEBUG(errs() << "Getting value " << *V << " on edge from '" + << FromBB->getName() << "' to '" << ToBB->getName() << "'\n"); + Result = GetValueOnEdge(V, FromBB, ToBB, BlockValues); + DEBUG(errs() << " Result = " << Result << "\n"); + } + + // If we know the value is a constant, evaluate the conditional. + Constant *Res = 0; + if (Result.isConstant()) { + Res = ConstantFoldCompareInstOperands(Pred, Result.getConstant(), C, TD); + if (ConstantInt *ResCI = dyn_cast_or_null(Res)) + return ResCI->isZero() ? False : True; + } else if (Result.isNotConstant()) { + // If this is an equality comparison, we can try to fold it knowing that + // "V != C1". + if (Pred == ICmpInst::ICMP_EQ) { + // !C1 == C -> false iff C1 == C. + Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE, + Result.getNotConstant(), C, TD); + if (Res->isNullValue()) + return False; + } else if (Pred == ICmpInst::ICMP_NE) { + // !C1 != C -> true iff C1 == C. + Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, + Result.getNotConstant(), C, TD); + if (Res->isNullValue()) + return True; + } } - // Not a very good implementation. return Unknown; } From sabre at nondot.org Wed Nov 11 22:37:50 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 04:37:50 -0000 Subject: [llvm-commits] [llvm] r86951 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911120437.nAC4boP5022361@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 22:37:50 2009 New Revision: 86951 URL: http://llvm.org/viewvc/llvm-project?rev=86951&view=rev Log: switch jump threading to use getPredicateOnEdge in one place making the new LVI stuff smart enough to subsume some special cases in the old code. Disable them when LVI is around, the testcase still passes. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86951&r1=86950&r2=86951&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 22:37:50 2009 @@ -377,6 +377,7 @@ // If comparing a live-in value against a constant, see if we know the // live-in value on any predecessors. if (LVI && isa(Cmp->getOperand(1)) && + Cmp->getType()->isInteger() && // Not vector compare. (!isa(Cmp->getOperand(0)) || cast(Cmp->getOperand(0))->getParent() != BB)) { Constant *RHSCst = cast(Cmp->getOperand(1)); @@ -384,14 +385,14 @@ for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { // If the value is known by LazyValueInfo to be a constant in a // predecessor, use that information to try to thread this block. - Constant *PredCst = LVI->getConstantOnEdge(Cmp->getOperand(0), *PI, BB); - if (PredCst == 0) + LazyValueInfo::Tristate + Res = LVI->getPredicateOnEdge(Cmp->getPredicate(), Cmp->getOperand(0), + RHSCst, *PI, BB); + if (Res == LazyValueInfo::Unknown) continue; - - // Constant fold the compare. - Value *Res = SimplifyCmpInst(Cmp->getPredicate(), PredCst, RHSCst, TD); - if (isa(Res) || isa(Res)) - Result.push_back(std::make_pair(dyn_cast(Res), *PI)); + + Constant *ResC = ConstantInt::get(Cmp->getType(), Res); + Result.push_back(std::make_pair(cast(ResC), *PI)); } return !Result.empty(); @@ -498,7 +499,8 @@ // br COND, BBX, BBY // BBX: // br COND, BBZ, BBW - if (!Condition->hasOneUse() && // Multiple uses. + if (!LVI && + !Condition->hasOneUse() && // Multiple uses. (CondInst == 0 || CondInst->getParent() != BB)) { // Non-local definition. pred_iterator PI = pred_begin(BB), E = pred_end(BB); if (isa(BB->getTerminator())) { @@ -532,8 +534,9 @@ return ProcessJumpOnPHI(PN); if (CmpInst *CondCmp = dyn_cast(CondInst)) { - if (!isa(CondCmp->getOperand(0)) || - cast(CondCmp->getOperand(0))->getParent() != BB) { + if (!LVI && + (!isa(CondCmp->getOperand(0)) || + cast(CondCmp->getOperand(0))->getParent() != BB)) { // If we have a comparison, loop over the predecessors to see if there is // a condition with a lexically identical value. pred_iterator PI = pred_begin(BB), E = pred_end(BB); From sabre at nondot.org Wed Nov 11 22:57:14 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 04:57:14 -0000 Subject: [llvm-commits] [llvm] r86952 - in /llvm/trunk/lib: Analysis/LazyValueInfo.cpp Transforms/Scalar/JumpThreading.cpp Message-ID: <200911120457.nAC4vF3H022928@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 22:57:13 2009 New Revision: 86952 URL: http://llvm.org/viewvc/llvm-project?rev=86952&view=rev Log: various fixes to the lattice transfer functions. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86952&r1=86951&r2=86952&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 22:57:13 2009 @@ -141,19 +141,40 @@ if (RHS.isNotConstant()) { if (isNotConstant()) { - if (getNotConstant() != RHS.getNotConstant()) + if (getNotConstant() != RHS.getNotConstant() || + isa(getNotConstant()) || + isa(RHS.getNotConstant())) return markOverdefined(); return false; } - if (isConstant() && getConstant() != RHS.getNotConstant()) - return markOverdefined(); + if (isConstant()) { + if (getConstant() == RHS.getNotConstant() || + isa(RHS.getNotConstant()) || + isa(getConstant())) + return markOverdefined(); + return markNotConstant(RHS.getNotConstant()); + } + + assert(isUndefined() && "Unexpected lattice"); return markNotConstant(RHS.getNotConstant()); } - // RHS must be a constant, we must be undef or constant. - if (isConstant() && getConstant() != RHS.getConstant()) + // RHS must be a constant, we must be undef, constant, or notconstant. + if (isUndefined()) + return markConstant(RHS.getConstant()); + + if (isConstant()) { + if (getConstant() != RHS.getConstant()) + return markOverdefined(); + return false; + } + + // If we are known "!=4" and RHS is "==5", stay at "!=4". + if (getNotConstant() == RHS.getConstant() || + isa(getNotConstant()) || + isa(RHS.getConstant())) return markOverdefined(); - return markConstant(RHS.getConstant()); + return false; } }; Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86952&r1=86951&r2=86952&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 22:57:13 2009 @@ -275,6 +275,12 @@ /// predecessor based on its terminator. // if (LVI) { + // FIXME: change this to use the more-rich 'getPredicateOnEdge' method if + // "I" is a non-local compare-with-a-constant instruction. This would be + // able to handle value inequalities better, for example if the compare is + // "X < 4" and "X < 3" is known true but "X < 4" itself is not available. + // Perhaps getConstantOnEdge should be smart enough to do this? + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { // If the value is known by LazyValueInfo to be a constant in a // predecessor, use that information to try to thread this block. From sabre at nondot.org Wed Nov 11 23:24:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 05:24:05 -0000 Subject: [llvm-commits] [llvm] r86953 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911120524.nAC5O5pc023731@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 11 23:24:05 2009 New Revision: 86953 URL: http://llvm.org/viewvc/llvm-project?rev=86953&view=rev Log: use getPredicateOnEdge to fold comparisons through PHI nodes, which implements GCC PR18046. This also gets us 360 more jump threads on 176.gcc. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86953&r1=86952&r2=86953&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 23:24:05 2009 @@ -368,7 +368,17 @@ Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); Value *Res = SimplifyCmpInst(Cmp->getPredicate(), LHS, RHS, TD); - if (Res == 0) continue; + if (Res == 0) { + if (!LVI || !isa(RHS)) + continue; + + LazyValueInfo::Tristate + ResT = LVI->getPredicateOnEdge(Cmp->getPredicate(), LHS, + cast(RHS), PredBB, BB); + if (ResT == LazyValueInfo::Unknown) + continue; + Res = ConstantInt::get(Type::getInt1Ty(LHS->getContext()), ResT); + } if (isa(Res)) Result.push_back(std::make_pair((ConstantInt*)0, PredBB)); Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86953&r1=86952&r2=86953&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Wed Nov 11 23:24:05 2009 @@ -349,6 +349,38 @@ ret i32 4 } +;; Correlated value through boolean expression. GCC PR18046. +define void @test12(i32 %A) { +; CHECK: @test12 +entry: + %cond = icmp eq i32 %A, 0 + br i1 %cond, label %bb, label %bb1 +; Should branch to the return block instead of through BB1. +; CHECK: entry: +; CHECK-NEXT: %cond = icmp eq i32 %A, 0 +; CHECK-NEXT: br i1 %cond, label %bb1, label %return + +bb: + %B = call i32 @test10f2() + br label %bb1 + +bb1: + %C = phi i32 [ %A, %entry ], [ %B, %bb ] + %cond4 = icmp eq i32 %C, 0 + br i1 %cond4, label %bb2, label %return + +; CHECK: bb1: +; CHECK-NEXT: %B = call i32 @test10f2() +; CHECK-NEXT: %cond4 = icmp eq i32 %B, 0 +; CHECK-NEXT: br i1 %cond4, label %bb2, label %return + +bb2: + %D = call i32 @test10f2() + ret void + +return: + ret void +} ;;; Duplicate condition to avoid xor of cond. From ofv at wanadoo.es Wed Nov 11 23:36:09 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Thu, 12 Nov 2009 05:36:09 -0000 Subject: [llvm-commits] [llvm] r86954 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake Message-ID: <200911120536.nAC5aArj024086@zion.cs.uiuc.edu> Author: ofv Date: Wed Nov 11 23:36:09 2009 New Revision: 86954 URL: http://llvm.org/viewvc/llvm-project?rev=86954&view=rev Log: CMake: Pass -lm to check_symbol_exists for detecting several math functions like floorf, ceilf, ... Add test for detecting nearbyintf. This change was prompted by test/Transforms/SimplifyLibCalls/floor.ll Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/include/llvm/Config/config.h.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86954&r1=86953&r2=86954&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Wed Nov 11 23:36:09 2009 @@ -4,6 +4,11 @@ include(CheckFunctionExists) include(CheckCXXSourceCompiles) +if( UNIX ) + # Used by check_symbol_exists: + set(CMAKE_REQUIRED_LIBRARIES m) +endif() + # Helper macros and functions macro(add_cxx_include result files) set(${result} "") @@ -84,6 +89,7 @@ check_symbol_exists(isnan math.h HAVE_ISNAN_IN_MATH_H) check_symbol_exists(ceilf math.h HAVE_CEILF) check_symbol_exists(floorf math.h HAVE_FLOORF) +check_symbol_exists(nearbyintf math.h HAVE_NEARBYINTF) check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO) check_symbol_exists(malloc_zone_statistics malloc/malloc.h HAVE_MALLOC_ZONE_STATISTICS) Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=86954&r1=86953&r2=86954&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Wed Nov 11 23:36:09 2009 @@ -253,7 +253,7 @@ #cmakedefine HAVE_NDIR_H ${HAVE_NDIR_H} /* Define to 1 if you have the `nearbyintf' function. */ -#undef HAVE_NEARBYINTF +#cmakedefine HAVE_NEARBYINTF ${HAVE_NEARBYINTF} /* Define if the neat program is available */ #cmakedefine HAVE_NEATO ${HAVE_NEATO} From rafael.espindola at gmail.com Wed Nov 11 23:46:10 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 12 Nov 2009 05:46:10 -0000 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in Message-ID: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> Author: rafael Date: Wed Nov 11 23:46:09 2009 New Revision: 86955 URL: http://llvm.org/viewvc/llvm-project?rev=86955&view=rev Log: Add the --with-c-include-dirs to llvm's configure. The clang patch is next. Modified: llvm/trunk/Makefile.config.in llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=86955&r1=86954&r2=86955&view=diff ============================================================================== --- llvm/trunk/Makefile.config.in (original) +++ llvm/trunk/Makefile.config.in Wed Nov 11 23:46:09 2009 @@ -313,6 +313,8 @@ # Location of the plugin header file for gold. BINUTILS_INCDIR := @BINUTILS_INCDIR@ +C_INCLUDE_DIRS := @C_INCLUDE_DISR@ + # When ENABLE_LLVMC_DYNAMIC is enabled, LLVMC will link libCompilerDriver # dynamically. This is needed to make dynamic plugins work on some targets # (Windows). Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=86955&r1=86954&r2=86955&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Wed Nov 11 23:46:09 2009 @@ -667,6 +667,13 @@ *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;; esac +AC_ARG_WITH(c-include-dir, + AS_HELP_STRING([--with-c-include-dirs], + [Colon separated list of directories clang will search for headers]),, + withval="") +AC_DEFINE_UNQUOTED(C_INCLUDE_DIRS,"$withval", + [Directories clang will search for headers]) + dnl Allow linking of LLVM with GPLv3 binutils code. AC_ARG_WITH(binutils-include, AS_HELP_STRING([--with-binutils-include], Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=86955&r1=86954&r2=86955&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Wed Nov 11 23:46:09 2009 @@ -1603,6 +1603,8 @@ --with-extra-options Specify additional options to compile LLVM with --with-ocaml-libdir Specify install location for ocaml bindings (default is stdlib) + --with-c-include-dirs Colon separated list of directories clang will + search for headers --with-binutils-include Specify path to binutils/include/ containing plugin-api.h file for gold plugin. --with-tclinclude directory where tcl headers are @@ -5272,6 +5274,20 @@ esac +# Check whether --with-c-include-dir was given. +if test "${with_c_include_dir+set}" = set; then + withval=$with_c_include_dir; +else + withval="" +fi + + +cat >>confdefs.h <<_ACEOF +#define C_INCLUDE_DIRS "$withval" +_ACEOF + + + # Check whether --with-binutils-include was given. if test "${with_binutils_include+set}" = set; then withval=$with_binutils_include; @@ -11036,7 +11052,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 13199 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14898,11 +14914,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14901: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14917: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14905: \$? = $ac_status" >&5 + echo "$as_me:14921: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15166,11 +15182,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15169: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15185: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15173: \$? = $ac_status" >&5 + echo "$as_me:15189: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15270,11 +15286,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15273: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15289: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15277: \$? = $ac_status" >&5 + echo "$as_me:15293: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17722,7 +17738,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:20209: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20197: \$? = $ac_status" >&5 + echo "$as_me:20213: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20294,11 +20310,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20297: $lt_compile\"" >&5) + (eval echo "\"\$as_me:20313: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20301: \$? = $ac_status" >&5 + echo "$as_me:20317: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21864,11 +21880,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21883: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21871: \$? = $ac_status" >&5 + echo "$as_me:21887: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21968,11 +21984,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21971: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21987: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21975: \$? = $ac_status" >&5 + echo "$as_me:21991: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24203,11 +24219,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24206: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24222: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24210: \$? = $ac_status" >&5 + echo "$as_me:24226: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24471,11 +24487,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24474: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24490: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24478: \$? = $ac_status" >&5 + echo "$as_me:24494: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24575,11 +24591,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24578: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24594: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24582: \$? = $ac_status" >&5 + echo "$as_me:24598: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=86955&r1=86954&r2=86955&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Wed Nov 11 23:46:09 2009 @@ -11,6 +11,9 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Directories clang will search for headers */ +#undef C_INCLUDE_DIRS + /* Define if CBE is enabled for printf %a output */ #undef ENABLE_CBE_PRINTF_A From ofv at wanadoo.es Thu Nov 12 00:00:34 2009 From: ofv at wanadoo.es (=?windows-1252?Q?=D3scar_Fuentes?=) Date: Thu, 12 Nov 2009 07:00:34 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> Message-ID: <87k4xw5lkt.fsf@telefonica.net> Rafael Espindola writes: > URL: http://llvm.org/viewvc/llvm-project?rev=86955&view=rev > Log: > Add the --with-c-include-dirs to llvm's configure. > The clang patch is next. > > > Modified: > llvm/trunk/Makefile.config.in > llvm/trunk/autoconf/configure.ac > llvm/trunk/configure > llvm/trunk/include/llvm/Config/config.h.in Do you (the LLVM devs) consider that it is really okay to use the LLVM config.h file for stuff specific of clang (or any other project that is not LLVM proper)? I understand that right now this is forced by the build infraestructure, but isn't the Right Thing to move clang outside LLVM or, at least, provide it with its own config mechanism, as gcc does with libstdc++, for instance? As far as the CMake build is concerned, it is perfectly feasible to move clang away and use LLVM as a clang component (the opposite scenario of we have now). Is it too hard to do this for config&make build? -- ?scar From espindola at google.com Thu Nov 12 00:18:52 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 12 Nov 2009 01:18:52 -0500 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <87k4xw5lkt.fsf@telefonica.net> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> Message-ID: <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> > As far as the CMake build is concerned, it is perfectly feasible to move > clang away and use LLVM as a clang component (the opposite scenario of > we have now). Is it too hard to do this for config&make build? Probably not. The way gcc does this is by having each major subdirectory have a configure script that run by make. We could also try to allow projects to have macros that are included at configure creation time. The second option avoids having a second annoying configure script in the build ... > -- > ?scar > Cheers, -- Rafael ?vila de Esp?ndola From ofv at wanadoo.es Thu Nov 12 00:48:09 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Thu, 12 Nov 2009 06:48:09 -0000 Subject: [llvm-commits] [llvm] r86960 - in /llvm/trunk: CMakeLists.txt include/llvm/Config/config.h.cmake Message-ID: <200911120648.nAC6m9Fm026287@zion.cs.uiuc.edu> Author: ofv Date: Thu Nov 12 00:48:09 2009 New Revision: 86960 URL: http://llvm.org/viewvc/llvm-project?rev=86960&view=rev Log: CMake: Hopefully unbreak the build by mimicking the changes on the other build system about the new C_INCLUDE_DIRS configure option. Modified: llvm/trunk/CMakeLists.txt llvm/trunk/include/llvm/Config/config.h.cmake Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=86960&r1=86959&r2=86960&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Thu Nov 12 00:48:09 2009 @@ -70,6 +70,9 @@ CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") endif( MSVC ) +set(C_INCLUDE_DIRS "" CACHE STRING + "Colon separated list of directories clang will search for headers.") + set(LLVM_TARGET_ARCH "host" CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=86960&r1=86959&r2=86960&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Thu Nov 12 00:48:09 2009 @@ -9,6 +9,9 @@ /* Define if CBE is enabled for printf %a output */ #undef ENABLE_CBE_PRINTF_A +/* Directories clang will search for headers */ +#define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" + /* Define if position independent code is enabled */ #cmakedefine ENABLE_PIC ${ENABLE_PIC} From evan.cheng at apple.com Thu Nov 12 01:13:12 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 07:13:12 -0000 Subject: [llvm-commits] [llvm] r86964 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h Message-ID: <200911120713.nAC7DCEg027035@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 12 01:13:11 2009 New Revision: 86964 URL: http://llvm.org/viewvc/llvm-project?rev=86964&view=rev Log: isLegalICmpImmediate should take a signed integer; code clean up. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=86964&r1=86963&r2=86964&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Nov 12 01:13:11 2009 @@ -1518,7 +1518,7 @@ /// icmp immediate, that is the target has icmp instructions which can compare /// a register against the immediate without having to materialize the /// immediate into a register. - virtual bool isLegalICmpImmediate(uint64_t Imm) const { + virtual bool isLegalICmpImmediate(int64_t Imm) const { return true; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=86964&r1=86963&r2=86964&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Nov 12 01:13:11 2009 @@ -1733,46 +1733,41 @@ return false; } -static bool isLegalCmpImmediate(unsigned C, bool isThumb1Only) { - return ( isThumb1Only && (C & ~255U) == 0) || - (!isThumb1Only && ARM_AM::getSOImmVal(C) != -1); -} - /// Returns appropriate ARM CMP (cmp) and corresponding condition code for /// the given operands. -static SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, - SDValue &ARMCC, SelectionDAG &DAG, bool isThumb1Only, - DebugLoc dl) { +SDValue +ARMTargetLowering::getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, + SDValue &ARMCC, SelectionDAG &DAG, DebugLoc dl) { if (ConstantSDNode *RHSC = dyn_cast(RHS.getNode())) { unsigned C = RHSC->getZExtValue(); - if (!isLegalCmpImmediate(C, isThumb1Only)) { + if (!isLegalICmpImmediate(C)) { // Constant does not fit, try adjusting it by one? switch (CC) { default: break; case ISD::SETLT: case ISD::SETGE: - if (isLegalCmpImmediate(C-1, isThumb1Only)) { + if (isLegalICmpImmediate(C-1)) { CC = (CC == ISD::SETLT) ? ISD::SETLE : ISD::SETGT; RHS = DAG.getConstant(C-1, MVT::i32); } break; case ISD::SETULT: case ISD::SETUGE: - if (C > 0 && isLegalCmpImmediate(C-1, isThumb1Only)) { + if (C > 0 && isLegalICmpImmediate(C-1)) { CC = (CC == ISD::SETULT) ? ISD::SETULE : ISD::SETUGT; RHS = DAG.getConstant(C-1, MVT::i32); } break; case ISD::SETLE: case ISD::SETGT: - if (isLegalCmpImmediate(C+1, isThumb1Only)) { + if (isLegalICmpImmediate(C+1)) { CC = (CC == ISD::SETLE) ? ISD::SETLT : ISD::SETGE; RHS = DAG.getConstant(C+1, MVT::i32); } break; case ISD::SETULE: case ISD::SETUGT: - if (C < 0xffffffff && isLegalCmpImmediate(C+1, isThumb1Only)) { + if (C < 0xffffffff && isLegalICmpImmediate(C+1)) { CC = (CC == ISD::SETULE) ? ISD::SETULT : ISD::SETUGE; RHS = DAG.getConstant(C+1, MVT::i32); } @@ -1808,8 +1803,7 @@ return DAG.getNode(ARMISD::FMSTAT, dl, MVT::Flag, Cmp); } -static SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG, - const ARMSubtarget *ST) { +SDValue ARMTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) { EVT VT = Op.getValueType(); SDValue LHS = Op.getOperand(0); SDValue RHS = Op.getOperand(1); @@ -1821,7 +1815,7 @@ if (LHS.getValueType() == MVT::i32) { SDValue ARMCC; SDValue CCR = DAG.getRegister(ARM::CPSR, MVT::i32); - SDValue Cmp = getARMCmp(LHS, RHS, CC, ARMCC, DAG, ST->isThumb1Only(), dl); + SDValue Cmp = getARMCmp(LHS, RHS, CC, ARMCC, DAG, dl); return DAG.getNode(ARMISD::CMOV, dl, VT, FalseVal, TrueVal, ARMCC, CCR,Cmp); } @@ -1843,8 +1837,7 @@ return Result; } -static SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG, - const ARMSubtarget *ST) { +SDValue ARMTargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) { SDValue Chain = Op.getOperand(0); ISD::CondCode CC = cast(Op.getOperand(1))->get(); SDValue LHS = Op.getOperand(2); @@ -1855,7 +1848,7 @@ if (LHS.getValueType() == MVT::i32) { SDValue ARMCC; SDValue CCR = DAG.getRegister(ARM::CPSR, MVT::i32); - SDValue Cmp = getARMCmp(LHS, RHS, CC, ARMCC, DAG, ST->isThumb1Only(), dl); + SDValue Cmp = getARMCmp(LHS, RHS, CC, ARMCC, DAG, dl); return DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Chain, Dest, ARMCC, CCR,Cmp); } @@ -2138,8 +2131,7 @@ /// LowerShiftRightParts - Lower SRA_PARTS, which returns two /// i32 values and take a 2 x i32 value to shift plus a shift amount. -static SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG, - const ARMSubtarget *ST) { +SDValue ARMTargetLowering::LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) { assert(Op.getNumOperands() == 3 && "Not a double-shift!"); EVT VT = Op.getValueType(); unsigned VTBits = VT.getSizeInBits(); @@ -2163,7 +2155,7 @@ SDValue CCR = DAG.getRegister(ARM::CPSR, MVT::i32); SDValue Cmp = getARMCmp(ExtraShAmt, DAG.getConstant(0, MVT::i32), ISD::SETGE, - ARMCC, DAG, ST->isThumb1Only(), dl); + ARMCC, DAG, dl); SDValue Hi = DAG.getNode(Opc, dl, VT, ShOpHi, ShAmt); SDValue Lo = DAG.getNode(ARMISD::CMOV, dl, VT, FalseVal, TrueVal, ARMCC, CCR, Cmp); @@ -2174,8 +2166,7 @@ /// LowerShiftLeftParts - Lower SHL_PARTS, which returns two /// i32 values and take a 2 x i32 value to shift plus a shift amount. -static SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG, - const ARMSubtarget *ST) { +SDValue ARMTargetLowering::LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) { assert(Op.getNumOperands() == 3 && "Not a double-shift!"); EVT VT = Op.getValueType(); unsigned VTBits = VT.getSizeInBits(); @@ -2197,7 +2188,7 @@ SDValue FalseVal = DAG.getNode(ISD::OR, dl, VT, Tmp1, Tmp2); SDValue CCR = DAG.getRegister(ARM::CPSR, MVT::i32); SDValue Cmp = getARMCmp(ExtraShAmt, DAG.getConstant(0, MVT::i32), ISD::SETGE, - ARMCC, DAG, ST->isThumb1Only(), dl); + ARMCC, DAG, dl); SDValue Lo = DAG.getNode(ISD::SHL, dl, VT, ShOpLo, ShAmt); SDValue Hi = DAG.getNode(ARMISD::CMOV, dl, VT, FalseVal, Tmp3, ARMCC, CCR, Cmp); @@ -2883,8 +2874,8 @@ return Subtarget->isTargetDarwin() ? LowerGlobalAddressDarwin(Op, DAG) : LowerGlobalAddressELF(Op, DAG); case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG); - case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG, Subtarget); - case ISD::BR_CC: return LowerBR_CC(Op, DAG, Subtarget); + case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); + case ISD::BR_CC: return LowerBR_CC(Op, DAG); case ISD::BR_JT: return LowerBR_JT(Op, DAG); case ISD::DYNAMIC_STACKALLOC: return LowerDYNAMIC_STACKALLOC(Op, DAG); case ISD::VASTART: return LowerVASTART(Op, DAG, VarArgsFrameIndex); @@ -2901,9 +2892,9 @@ case ISD::SHL: case ISD::SRL: case ISD::SRA: return LowerShift(Op.getNode(), DAG, Subtarget); - case ISD::SHL_PARTS: return LowerShiftLeftParts(Op, DAG, Subtarget); + case ISD::SHL_PARTS: return LowerShiftLeftParts(Op, DAG); case ISD::SRL_PARTS: - case ISD::SRA_PARTS: return LowerShiftRightParts(Op, DAG, Subtarget); + case ISD::SRA_PARTS: return LowerShiftRightParts(Op, DAG); case ISD::VSETCC: return LowerVSETCC(Op, DAG); case ISD::BUILD_VECTOR: return LowerBUILD_VECTOR(Op, DAG); case ISD::VECTOR_SHUFFLE: return LowerVECTOR_SHUFFLE(Op, DAG); @@ -3710,12 +3701,12 @@ /// icmp immediate, that is the target has icmp instructions which can compare /// a register against the immediate without having to materialize the /// immediate into a register. -bool ARMTargetLowering::isLegalICmpImmediate(uint64_t Imm) const { +bool ARMTargetLowering::isLegalICmpImmediate(int64_t Imm) const { if (!Subtarget->isThumb()) return ARM_AM::getSOImmVal(Imm) != -1; if (Subtarget->isThumb2()) return ARM_AM::getT2SOImmVal(Imm) != -1; - return Imm < 256; + return Imm >= 0 && Imm <= 255; } static bool getARMIndexedAddressParts(SDNode *Ptr, EVT VT, Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=86964&r1=86963&r2=86964&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Thu Nov 12 01:13:11 2009 @@ -184,7 +184,7 @@ /// icmp immediate, that is the target has icmp instructions which can compare /// a register against the immediate without having to materialize the /// immediate into a register. - virtual bool isLegalICmpImmediate(uint64_t Imm) const; + virtual bool isLegalICmpImmediate(int64_t Imm) const; /// getPreIndexedAddressParts - returns true by value, base pointer and /// offset pointer and addressing mode by reference if the node's address @@ -284,8 +284,12 @@ SelectionDAG &DAG); SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG); SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG); + SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG); + SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG); SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG); SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG); + SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG); + SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG); SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, @@ -321,6 +325,9 @@ CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl &Outs, DebugLoc dl, SelectionDAG &DAG); + + SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, + SDValue &ARMCC, SelectionDAG &DAG, DebugLoc dl); }; } From evan.cheng at apple.com Thu Nov 12 01:16:34 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 07:16:34 -0000 Subject: [llvm-commits] [llvm] r86965 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200911120716.nAC7GZBq027135@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 12 01:16:34 2009 New Revision: 86965 URL: http://llvm.org/viewvc/llvm-project?rev=86965&view=rev Log: Use table to separate opcode from operands. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=86965&r1=86964&r2=86965&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Thu Nov 12 01:16:34 2009 @@ -146,7 +146,7 @@ // Use vldmia to load a Q register as a D register pair. def VLDRQ : NI4<(outs QPR:$dst), (ins addrmode4:$addr), IIC_fpLoadm, - "vldmia $addr, ${dst:dregpair}", + "vldmia\t$addr, ${dst:dregpair}", [(set QPR:$dst, (v2f64 (load addrmode4:$addr)))]> { let Inst{27-25} = 0b110; let Inst{24} = 0; // P bit @@ -158,7 +158,7 @@ // Use vstmia to store a Q register as a D register pair. def VSTRQ : NI4<(outs), (ins QPR:$src, addrmode4:$addr), IIC_fpStorem, - "vstmia $addr, ${src:dregpair}", + "vstmia\t$addr, ${src:dregpair}", [(store (v2f64 QPR:$src), addrmode4:$addr)]> { let Inst{27-25} = 0b110; let Inst{24} = 0; // P bit From evan.cheng at apple.com Thu Nov 12 01:35:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 07:35:05 -0000 Subject: [llvm-commits] [llvm] r86969 - in /llvm/trunk: include/llvm/Analysis/IVUsers.h lib/Analysis/IVUsers.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/Thumb2/lsr-deficiency.ll Message-ID: <200911120735.nAC7Z5S9027853@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 12 01:35:05 2009 New Revision: 86969 URL: http://llvm.org/viewvc/llvm-project?rev=86969&view=rev Log: - Teach LSR to avoid changing cmp iv stride if it will create an immediate that cannot be folded into target cmp instruction. - Avoid a phase ordering issue where early cmp optimization would prevent the later count-to-zero optimization. - Add missing checks which could cause LSR to reuse stride that does not have users. - Fix a bug in count-to-zero optimization code which failed to find the pre-inc iv's phi node. - Remove, tighten, loosen some incorrect checks disable valid transformations. - Quite a bit of code clean up. Added: llvm/trunk/test/CodeGen/Thumb2/lsr-deficiency.ll Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h llvm/trunk/lib/Analysis/IVUsers.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/IVUsers.h?rev=86969&r1=86968&r2=86969&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/IVUsers.h (original) +++ llvm/trunk/include/llvm/Analysis/IVUsers.h Thu Nov 12 01:35:05 2009 @@ -161,6 +161,10 @@ void addUser(const SCEV *Offset, Instruction *User, Value *Operand) { Users.push_back(new IVStrideUse(this, Offset, User, Operand)); } + + void removeUser(IVStrideUse *User) { + Users.erase(User); + } }; class IVUsers : public LoopPass { @@ -201,6 +205,9 @@ /// return true. Otherwise, return false. bool AddUsersIfInteresting(Instruction *I); + void AddUser(const SCEV *Stride, const SCEV *Offset, + Instruction *User, Value *Operand); + /// getReplacementExpr - Return a SCEV expression which computes the /// value of the OperandValToReplace of the given IVStrideUse. const SCEV *getReplacementExpr(const IVStrideUse &U) const; Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=86969&r1=86968&r2=86969&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Thu Nov 12 01:35:05 2009 @@ -267,6 +267,18 @@ return true; } +void IVUsers::AddUser(const SCEV *Stride, const SCEV *Offset, + Instruction *User, Value *Operand) { + IVUsersOfOneStride *StrideUses = IVUsesByStride[Stride]; + if (!StrideUses) { // First occurrence of this stride? + StrideOrder.push_back(Stride); + StrideUses = new IVUsersOfOneStride(Stride); + IVUses.push_back(StrideUses); + IVUsesByStride[Stride] = StrideUses; + } + IVUsesByStride[Stride]->addUser(Offset, User, Operand); +} + IVUsers::IVUsers() : LoopPass(&ID) { } Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=86969&r1=86968&r2=86969&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Nov 12 01:35:05 2009 @@ -132,13 +132,10 @@ } private: - ICmpInst *ChangeCompareStride(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse, - const SCEV *const * &CondStride); - void OptimizeIndvars(Loop *L); - void OptimizeLoopCountIV(const SCEV *Stride, - IVUsersOfOneStride &Uses, Loop *L); + + /// OptimizeLoopTermCond - Change loop terminating condition to use the + /// postinc iv when possible. void OptimizeLoopTermCond(Loop *L); /// OptimizeShadowIV - If IV is used in a int-to-float cast @@ -150,8 +147,27 @@ ICmpInst *OptimizeMax(Loop *L, ICmpInst *Cond, IVStrideUse* &CondUse); + /// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for + /// deciding when to exit the loop is used only for that purpose, try to + /// rearrange things so it counts down to a test against zero. + bool OptimizeLoopCountIV(Loop *L); + bool OptimizeLoopCountIVOfStride(const SCEV* &Stride, + IVStrideUse* &CondUse, Loop *L); + + /// StrengthReduceIVUsersOfStride - Strength reduce all of the users of a + /// single stride of IV. All of the users may have different starting + /// values, and this may not be the only stride. + void StrengthReduceIVUsersOfStride(const SCEV *const &Stride, + IVUsersOfOneStride &Uses, + Loop *L); + void StrengthReduceIVUsers(Loop *L); + + ICmpInst *ChangeCompareStride(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse, const SCEV* &CondStride, + bool PostPass = false); + bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, - const SCEV *const * &CondStride); + const SCEV* &CondStride); bool RequiresTypeConversion(const Type *Ty, const Type *NewTy); const SCEV *CheckForIVReuse(bool, bool, bool, const SCEV *const&, IVExpr&, const Type*, @@ -166,6 +182,7 @@ bool &AllUsesAreAddresses, bool &AllUsesAreOutsideLoop, std::vector &UsersToProcess); + bool StrideMightBeShared(const SCEV *Stride, Loop *L, bool CheckPreInc); bool ShouldUseFullStrengthReductionMode( const std::vector &UsersToProcess, const Loop *L, @@ -190,9 +207,7 @@ Instruction *IVIncInsertPt, const Loop *L, SCEVExpander &PreheaderRewriter); - void StrengthReduceStridedIVUsers(const SCEV *const &Stride, - IVUsersOfOneStride &Uses, - Loop *L); + void DeleteTriviallyDeadInstructions(); }; } @@ -1007,6 +1022,11 @@ if (SI == IVsByStride.end() || !isa(SI->first) || StrideNoReuse.count(SI->first)) continue; + // The other stride has no uses, don't reuse it. + std::map::iterator UI = + IU->IVUsesByStride.find(IU->StrideOrder[NewStride]); + if (UI->second->Users.empty()) + continue; int64_t SSInt = cast(SI->first)->getValue()->getSExtValue(); if (SI->first != Stride && (unsigned(abs64(SInt)) < SSInt || (SInt % SSInt) != 0)) @@ -1494,12 +1514,12 @@ return true; } -/// StrengthReduceStridedIVUsers - Strength reduce all of the users of a single +/// StrengthReduceIVUsersOfStride - Strength reduce all of the users of a single /// stride of IV. All of the users may have different starting values, and this /// may not be the only stride. -void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEV *const &Stride, - IVUsersOfOneStride &Uses, - Loop *L) { +void LoopStrengthReduce::StrengthReduceIVUsersOfStride(const SCEV *const &Stride, + IVUsersOfOneStride &Uses, + Loop *L) { // If all the users are moved to another stride, then there is nothing to do. if (Uses.Users.empty()) return; @@ -1778,11 +1798,28 @@ // different starting values, into different PHIs. } +void LoopStrengthReduce::StrengthReduceIVUsers(Loop *L) { + // Note: this processes each stride/type pair individually. All users + // passed into StrengthReduceIVUsersOfStride have the same type AND stride. + // Also, note that we iterate over IVUsesByStride indirectly by using + // StrideOrder. This extra layer of indirection makes the ordering of + // strides deterministic - not dependent on map order. + for (unsigned Stride = 0, e = IU->StrideOrder.size(); Stride != e; ++Stride) { + std::map::iterator SI = + IU->IVUsesByStride.find(IU->StrideOrder[Stride]); + assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); + // FIXME: Generalize to non-affine IV's. + if (!SI->first->isLoopInvariant(L)) + continue; + StrengthReduceIVUsersOfStride(SI->first, *SI->second, L); + } +} + /// FindIVUserForCond - If Cond has an operand that is an expression of an IV, /// set the IV user and stride information and return true, otherwise return /// false. bool LoopStrengthReduce::FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, - const SCEV *const * &CondStride) { + const SCEV* &CondStride) { for (unsigned Stride = 0, e = IU->StrideOrder.size(); Stride != e && !CondUse; ++Stride) { std::map::iterator SI = @@ -1796,7 +1833,7 @@ // InstCombine does it as well for simple uses, it's not clear that it // occurs enough in real life to handle. CondUse = UI; - CondStride = &SI->first; + CondStride = SI->first; return true; } } @@ -1854,8 +1891,9 @@ /// v1 = v1 + 3 /// if (v1 < 30) goto loop ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse, - const SCEV *const* &CondStride) { + IVStrideUse* &CondUse, + const SCEV* &CondStride, + bool PostPass) { // If there's only one stride in the loop, there's nothing to do here. if (IU->StrideOrder.size() < 2) return Cond; @@ -1863,23 +1901,31 @@ // trying to change the condition because the stride will still // remain. std::map::iterator I = - IU->IVUsesByStride.find(*CondStride); - if (I == IU->IVUsesByStride.end() || - I->second->Users.size() != 1) + IU->IVUsesByStride.find(CondStride); + if (I == IU->IVUsesByStride.end()) return Cond; + if (I->second->Users.size() > 1) { + for (ilist::iterator II = I->second->Users.begin(), + EE = I->second->Users.end(); II != EE; ++II) { + if (II->getUser() == Cond) + continue; + if (!isInstructionTriviallyDead(II->getUser())) + return Cond; + } + } // Only handle constant strides for now. - const SCEVConstant *SC = dyn_cast(*CondStride); + const SCEVConstant *SC = dyn_cast(CondStride); if (!SC) return Cond; ICmpInst::Predicate Predicate = Cond->getPredicate(); int64_t CmpSSInt = SC->getValue()->getSExtValue(); - unsigned BitWidth = SE->getTypeSizeInBits((*CondStride)->getType()); + unsigned BitWidth = SE->getTypeSizeInBits(CondStride->getType()); uint64_t SignBit = 1ULL << (BitWidth-1); const Type *CmpTy = Cond->getOperand(0)->getType(); const Type *NewCmpTy = NULL; unsigned TyBits = SE->getTypeSizeInBits(CmpTy); unsigned NewTyBits = 0; - const SCEV **NewStride = NULL; + const SCEV *NewStride = NULL; Value *NewCmpLHS = NULL; Value *NewCmpRHS = NULL; int64_t Scale = 1; @@ -1888,16 +1934,31 @@ if (ConstantInt *C = dyn_cast(Cond->getOperand(1))) { int64_t CmpVal = C->getValue().getSExtValue(); + // Check the relevant induction variable for conformance to + // the pattern. + const SCEV *IV = SE->getSCEV(Cond->getOperand(0)); + const SCEVAddRecExpr *AR = dyn_cast(IV); + if (!AR || !AR->isAffine()) + return Cond; + + const SCEVConstant *StartC = dyn_cast(AR->getStart()); // Check stride constant and the comparision constant signs to detect // overflow. - if ((CmpVal & SignBit) != (CmpSSInt & SignBit)) - return Cond; + if (StartC) { + if ((StartC->getValue()->getSExtValue() < CmpVal && CmpSSInt < 0) || + (StartC->getValue()->getSExtValue() > CmpVal && CmpSSInt > 0)) + return Cond; + } else { + // More restrictive check for the other cases. + if ((CmpVal & SignBit) != (CmpSSInt & SignBit)) + return Cond; + } // Look for a suitable stride / iv as replacement. for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { std::map::iterator SI = IU->IVUsesByStride.find(IU->StrideOrder[i]); - if (!isa(SI->first)) + if (!isa(SI->first) || SI->second->Users.empty()) continue; int64_t SSInt = cast(SI->first)->getValue()->getSExtValue(); if (SSInt == CmpSSInt || @@ -1907,6 +1968,14 @@ Scale = SSInt / CmpSSInt; int64_t NewCmpVal = CmpVal * Scale; + + // If old icmp value fits in icmp immediate field, but the new one doesn't + // try something else. + if (TLI && + TLI->isLegalICmpImmediate(CmpVal) && + !TLI->isLegalICmpImmediate(NewCmpVal)) + continue; + APInt Mul = APInt(BitWidth*2, CmpVal, true); Mul = Mul * APInt(BitWidth*2, Scale, true); // Check for overflow. @@ -1921,8 +1990,6 @@ (CmpVal & SignBit) != (NewCmpVal & SignBit)) continue; - if (NewCmpVal == CmpVal) - continue; // Pick the best iv to use trying to avoid a cast. NewCmpLHS = NULL; for (ilist::iterator UI = SI->second->Users.begin(), @@ -1972,19 +2039,21 @@ if (NewTyBits != TyBits && !isa(CondUse->getOffset())) continue; - bool AllUsesAreAddresses = true; - bool AllUsesAreOutsideLoop = true; - std::vector UsersToProcess; - const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, - AllUsesAreAddresses, - AllUsesAreOutsideLoop, - UsersToProcess); - // Avoid rewriting the compare instruction with an iv of new stride - // if it's likely the new stride uses will be rewritten using the - // stride of the compare instruction. - if (AllUsesAreAddresses && - ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess)) - continue; + if (!PostPass) { + bool AllUsesAreAddresses = true; + bool AllUsesAreOutsideLoop = true; + std::vector UsersToProcess; + const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, + AllUsesAreAddresses, + AllUsesAreOutsideLoop, + UsersToProcess); + // Avoid rewriting the compare instruction with an iv of new stride + // if it's likely the new stride uses will be rewritten using the + // stride of the compare instruction. + if (AllUsesAreAddresses && + ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess)) + continue; + } // Avoid rewriting the compare instruction with an iv which has // implicit extension or truncation built into it. @@ -1997,7 +2066,7 @@ if (Scale < 0 && !Cond->isEquality()) Predicate = ICmpInst::getSwappedPredicate(Predicate); - NewStride = &IU->StrideOrder[i]; + NewStride = IU->StrideOrder[i]; if (!isa(NewCmpTy)) NewCmpRHS = ConstantInt::get(NewCmpTy, NewCmpVal); else { @@ -2034,13 +2103,16 @@ Cond = new ICmpInst(OldCond, Predicate, NewCmpLHS, NewCmpRHS, L->getHeader()->getName() + ".termcond"); + DEBUG(errs() << " Change compare stride in Inst " << *OldCond); + DEBUG(errs() << " to " << *Cond << '\n'); + // Remove the old compare instruction. The old indvar is probably dead too. DeadInsts.push_back(CondUse->getOperandValToReplace()); OldCond->replaceAllUsesWith(Cond); OldCond->eraseFromParent(); - IU->IVUsesByStride[*NewStride]->addUser(NewOffset, Cond, NewCmpLHS); - CondUse = &IU->IVUsesByStride[*NewStride]->Users.back(); + IU->IVUsesByStride[NewStride]->addUser(NewOffset, Cond, NewCmpLHS); + CondUse = &IU->IVUsesByStride[NewStride]->Users.back(); CondStride = NewStride; ++NumEliminated; Changed = true; @@ -2300,6 +2372,113 @@ OptimizeShadowIV(L); } +bool LoopStrengthReduce::StrideMightBeShared(const SCEV* Stride, Loop *L, + bool CheckPreInc) { + int64_t SInt = cast(Stride)->getValue()->getSExtValue(); + for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { + std::map::iterator SI = + IU->IVUsesByStride.find(IU->StrideOrder[i]); + const SCEV *Share = SI->first; + if (!isa(SI->first) || Share == Stride) + continue; + int64_t SSInt = cast(Share)->getValue()->getSExtValue(); + if (SSInt == SInt) + return true; // This can definitely be reused. + if (unsigned(abs64(SSInt)) < SInt || (SSInt % SInt) != 0) + continue; + int64_t Scale = SSInt / SInt; + bool AllUsesAreAddresses = true; + bool AllUsesAreOutsideLoop = true; + std::vector UsersToProcess; + const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, + AllUsesAreAddresses, + AllUsesAreOutsideLoop, + UsersToProcess); + if (AllUsesAreAddresses && + ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess)) { + if (!CheckPreInc) + return true; + // Any pre-inc iv use? + IVUsersOfOneStride &StrideUses = *IU->IVUsesByStride[Share]; + for (ilist::iterator I = StrideUses.Users.begin(), + E = StrideUses.Users.end(); I != E; ++I) { + if (!I->isUseOfPostIncrementedValue()) + return true; + } + } + } + return false; +} + +/// isUsedByExitBranch - Return true if icmp is used by a loop terminating +/// conditional branch or it's and / or with other conditions before being used +/// as the condition. +static bool isUsedByExitBranch(ICmpInst *Cond, Loop *L) { + BasicBlock *CondBB = Cond->getParent(); + if (!L->isLoopExiting(CondBB)) + return false; + BranchInst *TermBr = dyn_cast(CondBB->getTerminator()); + if (!TermBr || !TermBr->isConditional()) + return false; + + Value *User = *Cond->use_begin(); + Instruction *UserInst = dyn_cast(User); + while (UserInst && + (UserInst->getOpcode() == Instruction::And || + UserInst->getOpcode() == Instruction::Or)) { + if (!UserInst->hasOneUse() || UserInst->getParent() != CondBB) + return false; + User = *User->use_begin(); + UserInst = dyn_cast(User); + } + return User == TermBr; +} + +static bool ShouldCountToZero(ICmpInst *Cond, IVStrideUse* &CondUse, + ScalarEvolution *SE, Loop *L, + const TargetLowering *TLI = 0) { + if (!L->contains(Cond->getParent())) + return false; + + if (!isa(CondUse->getOffset())) + return false; + + // Handle only tests for equality for the moment. + if (!Cond->isEquality() || !Cond->hasOneUse()) + return false; + if (!isUsedByExitBranch(Cond, L)) + return false; + + Value *CondOp0 = Cond->getOperand(0); + const SCEV *IV = SE->getSCEV(CondOp0); + const SCEVAddRecExpr *AR = dyn_cast(IV); + if (!AR || !AR->isAffine()) + return false; + + const SCEVConstant *SC = dyn_cast(AR->getStepRecurrence(*SE)); + if (!SC || SC->getValue()->getSExtValue() < 0) + // If it's already counting down, don't do anything. + return false; + + // If the RHS of the comparison is not an loop invariant, the rewrite + // cannot be done. Also bail out if it's already comparing against a zero. + // If we are checking this before cmp stride optimization, check if it's + // comparing against a already legal immediate. + Value *RHS = Cond->getOperand(1); + ConstantInt *RHSC = dyn_cast(RHS); + if (!L->isLoopInvariant(RHS) || + (RHSC && RHSC->isZero()) || + (RHSC && TLI && TLI->isLegalICmpImmediate(RHSC->getSExtValue()))) + return false; + + // Make sure the IV is only used for counting. Value may be preinc or + // postinc; 2 uses in either case. + if (!CondOp0->hasNUses(2)) + return false; + + return true; +} + /// OptimizeLoopTermCond - Change loop terminating condition to use the /// postinc iv when possible. void LoopStrengthReduce::OptimizeLoopTermCond(Loop *L) { @@ -2321,64 +2500,39 @@ // Search IVUsesByStride to find Cond's IVUse if there is one. IVStrideUse *CondUse = 0; - const SCEV *const *CondStride = 0; + const SCEV *CondStride = 0; ICmpInst *Cond = cast(TermBr->getCondition()); if (!FindIVUserForCond(Cond, CondUse, CondStride)) - return; // setcc doesn't use the IV. + return; + bool UsePostInc = true; if (ExitingBlock != LatchBlock) { - if (!Cond->hasOneUse()) + if (Cond->hasOneUse()) { // See below, we don't want the condition to be cloned. - return; - // If exiting block is the latch block, we know it's safe and profitable to - // transform the icmp to use post-inc iv. Otherwise do so only if it would - // not reuse another iv and its iv would be reused by other uses. We are - // optimizing for the case where the icmp is the only use of the iv. - IVUsersOfOneStride &StrideUses = *IU->IVUsesByStride[*CondStride]; - for (ilist::iterator I = StrideUses.Users.begin(), - E = StrideUses.Users.end(); I != E; ++I) { - if (I->getUser() == Cond) - continue; - if (!I->isUseOfPostIncrementedValue()) - return; - } - - // FIXME: This is expensive, and worse still ChangeCompareStride does a - // similar check. Can we perform all the icmp related transformations after - // StrengthReduceStridedIVUsers? - if (const SCEVConstant *SC = dyn_cast(*CondStride)) { - int64_t SInt = SC->getValue()->getSExtValue(); - for (unsigned NewStride = 0, ee = IU->StrideOrder.size(); NewStride != ee; - ++NewStride) { - std::map::iterator SI = - IU->IVUsesByStride.find(IU->StrideOrder[NewStride]); - if (!isa(SI->first) || SI->first == *CondStride) - continue; - int64_t SSInt = - cast(SI->first)->getValue()->getSExtValue(); - if (SSInt == SInt) - return; // This can definitely be reused. - if (unsigned(abs64(SSInt)) < SInt || (SSInt % SInt) != 0) + // If exiting block is the latch block, we know it's safe and profitable + // to transform the icmp to use post-inc iv. Otherwise do so only if it + // would not reuse another iv and its iv would be reused by other uses. + // We are optimizing for the case where the icmp is the only use of the + // iv. + IVUsersOfOneStride &StrideUses = *IU->IVUsesByStride[CondStride]; + for (ilist::iterator I = StrideUses.Users.begin(), + E = StrideUses.Users.end(); I != E; ++I) { + if (I->getUser() == Cond) continue; - int64_t Scale = SSInt / SInt; - bool AllUsesAreAddresses = true; - bool AllUsesAreOutsideLoop = true; - std::vector UsersToProcess; - const SCEV *CommonExprs = CollectIVUsers(SI->first, *SI->second, L, - AllUsesAreAddresses, - AllUsesAreOutsideLoop, - UsersToProcess); - // Avoid rewriting the compare instruction with an iv of new stride - // if it's likely the new stride uses will be rewritten using the - // stride of the compare instruction. - if (AllUsesAreAddresses && - ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess)) - return; + if (!I->isUseOfPostIncrementedValue()) { + UsePostInc = false; + break; + } } } - StrideNoReuse.insert(*CondStride); + // If iv for the stride might be shared and any of the users use pre-inc iv + // might be used, then it's not safe to use post-inc iv. + if (UsePostInc && + isa(CondStride) && + StrideMightBeShared(CondStride, L, true)) + UsePostInc = false; } // If the trip count is computed in terms of a max (due to ScalarEvolution @@ -2387,9 +2541,19 @@ Cond = OptimizeMax(L, Cond, CondUse); // If possible, change stride and operands of the compare instruction to - // eliminate one stride. - if (ExitingBlock == LatchBlock) - Cond = ChangeCompareStride(L, Cond, CondUse, CondStride); + // eliminate one stride. However, avoid rewriting the compare instruction with + // an iv of new stride if it's likely the new stride uses will be rewritten + // using the stride of the compare instruction. + if (ExitingBlock == LatchBlock && isa(CondStride)) { + // If the condition stride is a constant and it's the only use, we might + // want to optimize it first by turning it to count toward zero. + if (!StrideMightBeShared(CondStride, L, false) && + !ShouldCountToZero(Cond, CondUse, SE, L, TLI)) + Cond = ChangeCompareStride(L, Cond, CondUse, CondStride); + } + + if (!UsePostInc) + return; // It's possible for the setcc instruction to be anywhere in the loop, and // possible for it to have multiple users. If it is not immediately before @@ -2404,108 +2568,51 @@ LatchBlock->getInstList().insert(TermBr, Cond); // Clone the IVUse, as the old use still exists! - IU->IVUsesByStride[*CondStride]->addUser(CondUse->getOffset(), Cond, + IU->IVUsesByStride[CondStride]->addUser(CondUse->getOffset(), Cond, CondUse->getOperandValToReplace()); - CondUse = &IU->IVUsesByStride[*CondStride]->Users.back(); + CondUse = &IU->IVUsesByStride[CondStride]->Users.back(); } } // If we get to here, we know that we can transform the setcc instruction to // use the post-incremented version of the IV, allowing us to coalesce the // live ranges for the IV correctly. - CondUse->setOffset(SE->getMinusSCEV(CondUse->getOffset(), *CondStride)); + CondUse->setOffset(SE->getMinusSCEV(CondUse->getOffset(), CondStride)); CondUse->setIsUseOfPostIncrementedValue(true); Changed = true; ++NumLoopCond; } -/// isUsedByExitBranch - Return true if icmp is used by a loop terminating -/// conditional branch or it's and / or with other conditions before being used -/// as the condition. -static bool isUsedByExitBranch(ICmpInst *Cond, Loop *L) { - BasicBlock *CondBB = Cond->getParent(); - if (!L->isLoopExiting(CondBB)) - return false; - BranchInst *TermBr = dyn_cast(CondBB->getTerminator()); - if (!TermBr || !TermBr->isConditional()) - return false; - - Value *User = *Cond->use_begin(); - Instruction *UserInst = dyn_cast(User); - while (UserInst && - (UserInst->getOpcode() == Instruction::And || - UserInst->getOpcode() == Instruction::Or)) { - if (!UserInst->hasOneUse() || UserInst->getParent() != CondBB) - return false; - User = *User->use_begin(); - UserInst = dyn_cast(User); - } - return User == TermBr; -} - -/// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for deciding -/// when to exit the loop is used only for that purpose, try to rearrange things -/// so it counts down to a test against zero which tends to be cheaper. -void LoopStrengthReduce::OptimizeLoopCountIV(const SCEV *Stride, - IVUsersOfOneStride &Uses, - Loop *L) { - if (Uses.Users.size() != 1) - return; - +bool LoopStrengthReduce::OptimizeLoopCountIVOfStride(const SCEV* &Stride, + IVStrideUse* &CondUse, + Loop *L) { // If the only use is an icmp of an loop exiting conditional branch, then // attempts the optimization. - BasedUser User = BasedUser(*Uses.Users.begin(), SE); - Instruction *Inst = User.Inst; - if (!L->contains(Inst->getParent())) - return; - - ICmpInst *Cond = dyn_cast(Inst); - if (!Cond) - return; - // Handle only tests for equality for the moment. - if (Cond->getPredicate() != CmpInst::ICMP_EQ || !Cond->hasOneUse()) - return; - if (!isUsedByExitBranch(Cond, L)) - return; - - Value *CondOp0 = Cond->getOperand(0); - const SCEV *IV = SE->getSCEV(CondOp0); - const SCEVAddRecExpr *AR = dyn_cast(IV); - if (!AR || !AR->isAffine()) - return; + BasedUser User = BasedUser(*CondUse, SE); + assert(isa(User.Inst) && "Expecting an ICMPInst!"); + ICmpInst *Cond = cast(User.Inst); - const SCEVConstant *SC = dyn_cast(AR->getStepRecurrence(*SE)); - if (!SC || SC->getValue()->getSExtValue() < 0) - // If it's already counting down, don't do anything. - return; - - // If the RHS of the comparison is not an loop invariant, the rewrite - // cannot be done. Also bail out if it's already comparing against a zero. - Value *RHS = Cond->getOperand(1); - if (!L->isLoopInvariant(RHS) || - (isa(RHS) && cast(RHS)->isZero())) - return; + // Less strict check now that compare stride optimization is done. + if (!ShouldCountToZero(Cond, CondUse, SE, L)) + return false; - // Make sure the IV is only used for counting. Value may be preinc or - // postinc; 2 uses in either case. - if (!CondOp0->hasNUses(2)) - return; - PHINode *PHIExpr; + Value *CondOp0 = Cond->getOperand(0); + PHINode *PHIExpr = dyn_cast(CondOp0); Instruction *Incr; - if (User.isUseOfPostIncrementedValue) { + if (!PHIExpr) { // Value tested is postinc. Find the phi node. Incr = dyn_cast(CondOp0); + // FIXME: Just use User.OperandValToReplace here? if (!Incr || Incr->getOpcode() != Instruction::Add) - return; + return false; - Instruction::use_iterator UI = CondOp0->use_begin(); - PHIExpr = dyn_cast(UI); + PHIExpr = dyn_cast(Incr->getOperand(0)); if (!PHIExpr) - PHIExpr = dyn_cast(++UI); + return false; // 1 use for preinc value, the increment. - if (!PHIExpr || !PHIExpr->hasOneUse()) - return; + if (!PHIExpr->hasOneUse()) + return false; } else { assert(isa(CondOp0) && "Unexpected loop exiting counting instruction sequence!"); @@ -2518,18 +2625,13 @@ Incr = dyn_cast(++UI); // One use for postinc value, the phi. Unnecessarily conservative? if (!Incr || !Incr->hasOneUse() || Incr->getOpcode() != Instruction::Add) - return; + return false; } // Replace the increment with a decrement. - DEBUG(errs() << " Examining "); - if (User.isUseOfPostIncrementedValue) - DEBUG(errs() << "postinc"); - else - DEBUG(errs() << "preinc"); - DEBUG(errs() << " use "); + DEBUG(errs() << "LSR: Examining use "); DEBUG(WriteAsOperand(errs(), CondOp0, /*PrintType=*/false)); - DEBUG(errs() << " in Inst: " << *Inst << '\n'); + DEBUG(errs() << " in Inst: " << *Cond << '\n'); BinaryOperator *Decr = BinaryOperator::Create(Instruction::Sub, Incr->getOperand(0), Incr->getOperand(1), "tmp", Incr); Incr->replaceAllUsesWith(Decr); @@ -2554,8 +2656,75 @@ Cond->setOperand(1, Zero); DEBUG(errs() << " New icmp: " << *Cond << "\n"); - Changed = true; + int64_t SInt = cast(Stride)->getValue()->getSExtValue(); + const SCEV *NewStride = 0; + bool Found = false; + for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { + const SCEV *OldStride = IU->StrideOrder[i]; + if (const SCEVConstant *SC = dyn_cast(OldStride)) + if (SC->getValue()->getSExtValue() == -SInt) { + Found = true; + NewStride = OldStride; + break; + } + } + + if (!Found) + NewStride = SE->getIntegerSCEV(-SInt, Stride->getType()); + IU->AddUser(NewStride, CondUse->getOffset(), Cond, Cond->getOperand(0)); + IU->IVUsesByStride[Stride]->removeUser(CondUse); + + CondUse = &IU->IVUsesByStride[NewStride]->Users.back(); + Stride = NewStride; + ++NumCountZero; + + return true; +} + +/// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for deciding +/// when to exit the loop is used only for that purpose, try to rearrange things +/// so it counts down to a test against zero. +bool LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) { + bool ThisChanged = false; + for (unsigned i = 0, e = IU->StrideOrder.size(); i != e; ++i) { + const SCEV *Stride = IU->StrideOrder[i]; + std::map::iterator SI = + IU->IVUsesByStride.find(Stride); + assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); + // FIXME: Generalize to non-affine IV's. + if (!SI->first->isLoopInvariant(L)) + continue; + // If stride is a constant and it has an icmpinst use, check if we can + // optimize the loop to count down. + if (isa(Stride) && SI->second->Users.size() == 1) { + Instruction *User = SI->second->Users.begin()->getUser(); + if (!isa(User)) + continue; + const SCEV *CondStride = Stride; + IVStrideUse *Use = &*SI->second->Users.begin(); + if (!OptimizeLoopCountIVOfStride(CondStride, Use, L)) + continue; + ThisChanged = true; + + // Now check if it's possible to reuse this iv for other stride uses. + for (unsigned j = 0, ee = IU->StrideOrder.size(); j != ee; ++j) { + const SCEV *SStride = IU->StrideOrder[j]; + if (SStride == CondStride) + continue; + std::map::iterator SII = + IU->IVUsesByStride.find(SStride); + assert(SII != IU->IVUsesByStride.end() && "Stride doesn't exist!"); + // FIXME: Generalize to non-affine IV's. + if (!SII->first->isLoopInvariant(L)) + continue; + // FIXME: Rewrite other stride using CondStride. + } + } + } + + Changed |= ThisChanged; + return ThisChanged; } bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) { @@ -2587,7 +2756,7 @@ // Change loop terminating condition to use the postinc iv when possible // and optimize loop terminating compare. FIXME: Move this after - // StrengthReduceStridedIVUsers? + // StrengthReduceIVUsersOfStride? OptimizeLoopTermCond(L); // FIXME: We can shrink overlarge IV's here. e.g. if the code has @@ -2603,34 +2772,11 @@ // IVsByStride keeps IVs for one particular loop. assert(IVsByStride.empty() && "Stale entries in IVsByStride?"); - // Note: this processes each stride/type pair individually. All users - // passed into StrengthReduceStridedIVUsers have the same type AND stride. - // Also, note that we iterate over IVUsesByStride indirectly by using - // StrideOrder. This extra layer of indirection makes the ordering of - // strides deterministic - not dependent on map order. - for (unsigned Stride = 0, e = IU->StrideOrder.size(); - Stride != e; ++Stride) { - std::map::iterator SI = - IU->IVUsesByStride.find(IU->StrideOrder[Stride]); - assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); - // FIXME: Generalize to non-affine IV's. - if (!SI->first->isLoopInvariant(L)) - continue; - StrengthReduceStridedIVUsers(SI->first, *SI->second, L); - } + StrengthReduceIVUsers(L); // After all sharing is done, see if we can adjust the loop to test against // zero instead of counting up to a maximum. This is usually faster. - for (unsigned Stride = 0, e = IU->StrideOrder.size(); - Stride != e; ++Stride) { - std::map::iterator SI = - IU->IVUsesByStride.find(IU->StrideOrder[Stride]); - assert(SI != IU->IVUsesByStride.end() && "Stride doesn't exist!"); - // FIXME: Generalize to non-affine IV's. - if (!SI->first->isLoopInvariant(L)) - continue; - OptimizeLoopCountIV(SI->first, *SI->second, L); - } + OptimizeLoopCountIV(L); } // We're done analyzing this loop; release all the state we built up for it. Added: llvm/trunk/test/CodeGen/Thumb2/lsr-deficiency.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/lsr-deficiency.ll?rev=86969&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/lsr-deficiency.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/lsr-deficiency.ll Thu Nov 12 01:35:05 2009 @@ -0,0 +1,37 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -relocation-model=pic | FileCheck %s +; rdar://7387640 + +; FIXME: We still need to rewrite array reference iv of stride -4 with loop +; count iv of stride -1. + + at G = external global i32 ; [#uses=2] + at array = external global i32* ; [#uses=1] + +define arm_apcscc void @t() nounwind optsize { +; CHECK: t: +; CHECK: mov.w r2, #4000 +; CHECK: movw r3, #1001 +entry: + %.pre = load i32* @G, align 4 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry +; CHECK: LBB1_1: +; CHECK: subs r3, #1 +; CHECK: cmp r3, #0 +; CHECK: sub.w r2, r2, #4 + %0 = phi i32 [ %.pre, %entry ], [ %3, %bb ] ; [#uses=1] + %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; [#uses=2] + %tmp5 = sub i32 1000, %indvar ; [#uses=1] + %1 = load i32** @array, align 4 ; [#uses=1] + %scevgep = getelementptr i32* %1, i32 %tmp5 ; [#uses=1] + %2 = load i32* %scevgep, align 4 ; [#uses=1] + %3 = add nsw i32 %2, %0 ; [#uses=2] + store i32 %3, i32* @G, align 4 + %indvar.next = add i32 %indvar, 1 ; [#uses=2] + %exitcond = icmp eq i32 %indvar.next, 1001 ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} From baldrick at free.fr Thu Nov 12 01:42:35 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Nov 2009 08:42:35 +0100 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll In-Reply-To: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> References: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> Message-ID: <4AFBBC6B.8010304@free.fr> Hi Dan, > Add support for tail duplication to BranchFolding, and extend > tail merging support to handle more cases. > - Recognize several cases where tail merging is beneficial even when > the tail size is smaller than the generic threshold. > - Make use of MachineInstrDesc::isBarrier to help detect > non-fallthrough blocks. > - Check for and avoid disrupting fall-through edges in more cases. can this result in a label being sucked off the end of a block, and moved into another? Exception handling labels come in pairs, and it would be wrong to move one of them without the other (even all the instructions in between). Ciao, Duncan. From evan.cheng at apple.com Thu Nov 12 01:49:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 07:49:10 -0000 Subject: [llvm-commits] [llvm] r86972 - in /llvm/trunk: lib/CodeGen/RegisterScavenging.cpp test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Message-ID: <200911120749.nAC7nAJY028312@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 12 01:49:10 2009 New Revision: 86972 URL: http://llvm.org/viewvc/llvm-project?rev=86972&view=rev Log: RegScavenger::enterBasicBlock should always reset register state. Added: llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=86972&r1=86971&r2=86972&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Thu Nov 12 01:49:10 2009 @@ -100,11 +100,8 @@ CalleeSavedRegs.set(CSRegs[i]); } - // RS used within emit{Pro,Epi}logue() - if (mbb != MBB) { - MBB = mbb; - initRegState(); - } + MBB = mbb; + initRegState(); Tracking = false; } Added: llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll?rev=86972&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Thu Nov 12 01:49:10 2009 @@ -0,0 +1,85 @@ +; RUN: llc < %s -mtriplethumbv7-apple-darwin10 + +%struct.OP = type { %struct.OP*, %struct.OP*, %struct.OP* ()*, i32, i16, i16, i8, i8 } +%struct.SV = type { i8*, i32, i32 } + +declare arm_apcscc void @Perl_mg_set(%struct.SV*) nounwind + +define arm_apcscc %struct.OP* @Perl_pp_complement() nounwind { +entry: + %0 = load %struct.SV** null, align 4 ; <%struct.SV*> [#uses=2] + br i1 undef, label %bb21, label %bb5 + +bb5: ; preds = %entry + br i1 undef, label %bb13, label %bb6 + +bb6: ; preds = %bb5 + br i1 undef, label %bb8, label %bb7 + +bb7: ; preds = %bb6 + %1 = getelementptr inbounds %struct.SV* %0, i32 0, i32 0 ; [#uses=1] + %2 = load i8** %1, align 4 ; [#uses=1] + %3 = getelementptr inbounds i8* %2, i32 12 ; [#uses=1] + %4 = bitcast i8* %3 to i32* ; [#uses=1] + %5 = load i32* %4, align 4 ; [#uses=1] + %storemerge5 = xor i32 %5, -1 ; [#uses=1] + call arm_apcscc void @Perl_sv_setiv(%struct.SV* undef, i32 %storemerge5) nounwind + %6 = getelementptr inbounds %struct.SV* undef, i32 0, i32 2 ; [#uses=1] + %7 = load i32* %6, align 4 ; [#uses=1] + %8 = and i32 %7, 16384 ; [#uses=1] + %9 = icmp eq i32 %8, 0 ; [#uses=1] + br i1 %9, label %bb12, label %bb11 + +bb8: ; preds = %bb6 + unreachable + +bb11: ; preds = %bb7 + call arm_apcscc void @Perl_mg_set(%struct.SV* undef) nounwind + br label %bb12 + +bb12: ; preds = %bb11, %bb7 + store %struct.SV* undef, %struct.SV** null, align 4 + br label %bb44 + +bb13: ; preds = %bb5 + %10 = call arm_apcscc i32 @Perl_sv_2uv(%struct.SV* %0) nounwind ; [#uses=0] + br i1 undef, label %bb.i, label %bb1.i + +bb.i: ; preds = %bb13 + call arm_apcscc void @Perl_sv_setiv(%struct.SV* undef, i32 undef) nounwind + br label %Perl_sv_setuv.exit + +bb1.i: ; preds = %bb13 + br label %Perl_sv_setuv.exit + +Perl_sv_setuv.exit: ; preds = %bb1.i, %bb.i + %11 = getelementptr inbounds %struct.SV* undef, i32 0, i32 2 ; [#uses=1] + %12 = load i32* %11, align 4 ; [#uses=1] + %13 = and i32 %12, 16384 ; [#uses=1] + %14 = icmp eq i32 %13, 0 ; [#uses=1] + br i1 %14, label %bb20, label %bb19 + +bb19: ; preds = %Perl_sv_setuv.exit + call arm_apcscc void @Perl_mg_set(%struct.SV* undef) nounwind + br label %bb20 + +bb20: ; preds = %bb19, %Perl_sv_setuv.exit + store %struct.SV* undef, %struct.SV** null, align 4 + br label %bb44 + +bb21: ; preds = %entry + br i1 undef, label %bb23, label %bb22 + +bb22: ; preds = %bb21 + unreachable + +bb23: ; preds = %bb21 + unreachable + +bb44: ; preds = %bb20, %bb12 + ret %struct.OP* undef +} + +declare arm_apcscc void @Perl_sv_setiv(%struct.SV*, i32) nounwind + +declare arm_apcscc i32 @Perl_sv_2uv(%struct.SV*) nounwind From sabre at nondot.org Thu Nov 12 01:56:08 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 07:56:08 -0000 Subject: [llvm-commits] [llvm] r86975 - in /llvm/trunk: lib/Transforms/IPO/Inliner.cpp test/Transforms/Inline/delete-call.ll Message-ID: <200911120756.nAC7u8bE028641@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 12 01:56:08 2009 New Revision: 86975 URL: http://llvm.org/viewvc/llvm-project?rev=86975&view=rev Log: implement a nice little efficiency hack in the inliner. Since we're now running IPSCCP early, and we run functionattrs interlaced with the inliner, we often (particularly for small or noop functions) completely propagate all of the information about a call to its call site in IPSSCP (making a call dead) and functionattrs is smart enough to realize that the function is readonly (because it is interlaced with inliner). To improve compile time and make the inliner threshold more accurate, realize that we don't have to inline dead readonly function calls. Instead, just delete the call. This happens all the time for C++ codes, here are some counters from opt/llvm-ld counting the number of times calls were deleted vs inlined on various apps: Tramp3d opt: 5033 inline - Number of call sites deleted, not inlined 24596 inline - Number of functions inlined llvm-ld: 667 inline - Number of functions deleted because all callers found 699 inline - Number of functions inlined 483.xalancbmk opt: 8096 inline - Number of call sites deleted, not inlined 62528 inline - Number of functions inlined llvm-ld: 217 inline - Number of allocas merged together 2158 inline - Number of functions inlined 471.omnetpp: 331 inline - Number of call sites deleted, not inlined 8981 inline - Number of functions inlined llvm-ld: 171 inline - Number of functions deleted because all callers found 629 inline - Number of functions inlined Deleting a call is much faster than inlining it, and is insensitive to the size of the callee. :) Added: llvm/trunk/test/Transforms/Inline/delete-call.ll Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=86975&r1=86974&r2=86975&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Nov 12 01:56:08 2009 @@ -32,6 +32,7 @@ using namespace llvm; STATISTIC(NumInlined, "Number of functions inlined"); +STATISTIC(NumCallsDeleted, "Number of call sites deleted, not inlined"); STATISTIC(NumDeleted, "Number of functions deleted because all callers found"); STATISTIC(NumMergedAllocas, "Number of allocas merged together"); @@ -336,23 +337,39 @@ for (unsigned CSi = 0; CSi != CallSites.size(); ++CSi) { CallSite CS = CallSites[CSi]; + Function *Caller = CS.getCaller(); Function *Callee = CS.getCalledFunction(); - // We can only inline direct calls to non-declarations. - if (Callee == 0 || Callee->isDeclaration()) continue; + + // If this call site is dead and it is to a readonly function, we should + // just delete the call instead of trying to inline it, regardless of + // size. This happens because IPSCCP propagates the result out of the + // call and then we're left with the dead call. + if (CS.getInstruction()->use_empty() && + !CS.getInstruction()->mayHaveSideEffects()) { + DEBUG(errs() << " -> Deleting dead call: " + << *CS.getInstruction() << "\n"); + // Update the call graph by deleting the edge from Callee to Caller. + CG[Caller]->removeCallEdgeFor(CS); + CS.getInstruction()->eraseFromParent(); + ++NumCallsDeleted; + } else { + // We can only inline direct calls to non-declarations. + if (Callee == 0 || Callee->isDeclaration()) continue; - // If the policy determines that we should inline this function, - // try to do so. - if (!shouldInline(CS)) - continue; + // If the policy determines that we should inline this function, + // try to do so. + if (!shouldInline(CS)) + continue; - Function *Caller = CS.getCaller(); - // Attempt to inline the function... - if (!InlineCallIfPossible(CS, CG, TD, InlinedArrayAllocas)) - continue; + // Attempt to inline the function... + if (!InlineCallIfPossible(CS, CG, TD, InlinedArrayAllocas)) + continue; + ++NumInlined; + } - // If we inlined the last possible call site to the function, delete the - // function body now. - if (Callee->use_empty() && Callee->hasLocalLinkage() && + // If we inlined or deleted the last possible call site to the function, + // delete the function body now. + if (Callee && Callee->use_empty() && Callee->hasLocalLinkage() && // TODO: Can remove if in SCC now. !SCCFunctions.count(Callee) && @@ -391,7 +408,6 @@ } --CSi; - ++NumInlined; Changed = true; LocalChange = true; } Added: llvm/trunk/test/Transforms/Inline/delete-call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/delete-call.ll?rev=86975&view=auto ============================================================================== --- llvm/trunk/test/Transforms/Inline/delete-call.ll (added) +++ llvm/trunk/test/Transforms/Inline/delete-call.ll Thu Nov 12 01:56:08 2009 @@ -0,0 +1,22 @@ +; RUN: opt %s -S -inline -functionattrs -stats |& grep {Number of call sites deleted, not inlined} +; RUN: opt %s -S -inline -stats |& grep {Number of functions inlined} + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" +target triple = "i386-apple-darwin9.8" + +define internal i32 @test(i32 %x, i32 %y, i32 %z) nounwind { +entry: + %0 = add nsw i32 %y, %z ; [#uses=1] + %1 = mul i32 %0, %x ; [#uses=1] + %2 = mul i32 %y, %z ; [#uses=1] + %3 = add nsw i32 %1, %2 ; [#uses=1] + ret i32 %3 +} + +define i32 @test2() nounwind { +entry: + %0 = call i32 @test(i32 1, i32 2, i32 4) nounwind ; [#uses=1] + ret i32 14 +} + + From ggreif at gmail.com Thu Nov 12 03:44:18 2009 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 12 Nov 2009 09:44:18 -0000 Subject: [llvm-commits] [llvm] r86980 - /llvm/trunk/test/Transforms/JumpThreading/basic.ll Message-ID: <200911120944.nAC9iIAW013785@zion.cs.uiuc.edu> Author: ggreif Date: Thu Nov 12 03:44:17 2009 New Revision: 86980 URL: http://llvm.org/viewvc/llvm-project?rev=86980&view=rev Log: typo Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86980&r1=86979&r2=86980&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Thu Nov 12 03:44:17 2009 @@ -302,7 +302,7 @@ ; CHECK: %v1 = call i32 @test10f1() ; CHECK-NEXT: call void @f3() -; CHeCK-NEXT: ret i32 %v1 +; CHECK-NEXT: ret i32 %v1 F1: %v2 = call i32 @test10f2() From baldrick at free.fr Thu Nov 12 03:48:26 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Nov 2009 10:48:26 +0100 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> Message-ID: <4AFBD9EA.4040907@free.fr> Hi Bill, > + bool DoesNotThrow = false; > + for (unsigned OI = 0, OE = MI->getNumOperands(); OI != OE; ++OI) { > + const MachineOperand &MO = MI->getOperand(OI); > + > + if (MO.isGlobal()) { > + if (Function *F = dyn_cast(MO.getGlobal())) { > + if (F->doesNotThrow()) { > + DoesNotThrow = true; > + break; > + } > + } > + } > + } doesn't this mean that if a pointer to a nounwind function is passed as a call parameter (rather than as the callee), then DoesNotThrow is set to true? Ciao, Duncan. From isanbard at gmail.com Thu Nov 12 03:52:35 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 12 Nov 2009 01:52:35 -0800 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <4AFBD9EA.4040907@free.fr> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> <4AFBD9EA.4040907@free.fr> Message-ID: <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> On Nov 12, 2009, at 1:48 AM, Duncan Sands wrote: >> + bool DoesNotThrow = false; >> + for (unsigned OI = 0, OE = MI->getNumOperands(); OI != OE; ++OI) { >> + const MachineOperand &MO = MI->getOperand(OI); >> + >> + if (MO.isGlobal()) { >> + if (Function *F = dyn_cast(MO.getGlobal())) { >> + if (F->doesNotThrow()) { >> + DoesNotThrow = true; >> + break; >> + } >> + } >> + } >> + } > > doesn't this mean that if a pointer to a nounwind function is passed as a > call parameter (rather than as the callee), then DoesNotThrow is set to true? > If such an instruction existed, then I suppose. What's the best way to determine that it's the "callee" and not a parameter? Do you have an example to work with? -bw From baldrick at free.fr Thu Nov 12 04:06:54 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Nov 2009 11:06:54 +0100 Subject: [llvm-commits] [llvm] r86975 - in /llvm/trunk: lib/Transforms/IPO/Inliner.cpp test/Transforms/Inline/delete-call.ll In-Reply-To: <200911120756.nAC7u8bE028641@zion.cs.uiuc.edu> References: <200911120756.nAC7u8bE028641@zion.cs.uiuc.edu> Message-ID: <4AFBDE3E.5090904@free.fr> Hi Chris, > + // If this call site is dead and it is to a readonly function, we should > + // just delete the call instead of trying to inline it, regardless of > + // size. This happens because IPSCCP propagates the result out of the > + // call and then we're left with the dead call. > + if (CS.getInstruction()->use_empty() && > + !CS.getInstruction()->mayHaveSideEffects()) { how about using isInstructionTriviallyDead here? Ciao, Duncan. From wangmp at apple.com Thu Nov 12 04:11:34 2009 From: wangmp at apple.com (Mon Ping Wang) Date: Thu, 12 Nov 2009 02:11:34 -0800 Subject: [llvm-commits] Patch for scalarized division. In-Reply-To: <1C8DE0332CB01445BF7ADEDE3DDD57071958D1D1@sausexmbp02.amd.com> References: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> <1C8DE0332CB01445BF7ADEDE3DDD57071958D1D1@sausexmbp02.amd.com> Message-ID: <4216CF46-9567-4652-826C-EF51AE9BFEC7@apple.com> Hi, We use to have a design where LegalizeOp did both type legalization and operation legalization. The problem with that approach was that after type legalization, there were opportunities for dag combiner to cleanup code and if it was one phase, we would miss these optimizations or have to teach legalization the optimizations that dag combiner has. Here is a patch for an alternative approach based on using the custom lowering hook. The default widening algorithm doesn't know if an operation doesn't have a vector equivalent nor if the operation can trap since this is target dependent. For these cases, widen will want to scalarize the operation and rebuild the vector and add any undefs at the end for the widen vector. This avoids generating the operation on undef. The patch adds the custom lowering node hook to Widening in Type Legalization. In the target machine, for any vector divide/ remainder operation that we would need to widen (i.e., vectors of illegal types), we would call the custom widen operation which does the above. I need to add a few test cases but it does fix the case you gave in your example. Please let me know what you think. -- Mon Ping On Nov 7, 2009, at 7:55 AM, Sjodin, Jan wrote: > I agree that this is not the ideal way to do things, and the list of > operations is indeed incomplete and may be different on different > targets. > The problem is that the type legalization is done without taking the > operations into account. A more general solution would be to combine > the type and ops legalization into one pass. A somewhat simpler > solution could be to scalarize operations first, then do the type > legalization and finally apply the non-scalarizing legalize vector > ops. I do not know if there are any cases where legalization needs > more information about the surrounding operations to produce correct > code. > > - Jan > > From: Mon Ping Wang [mailto:wangmp at apple.com] > Sent: Friday, November 06, 2009 11:59 PM > To: Sjodin, Jan > Cc: 'llvm-commits at cs.uiuc.edu' > Subject: Re: [llvm-commits] Patch for scalarized division. > > Hi Jan, > > Some quick comments about the patch. > > @@ -282,6 +289,95 @@ SDValue VectorLegalizer::UnrollVSETCC(SD > > +bool VectorLegalizer::rangeIsDefined(SDValue Op, > + uint64_t LoBitIndex, > + uint64_t HiBitIndex) > +{ > +[Deleted Code] > + case ISD::ADD: > + case ISD::SUB: > + case ISD::MUL: > + case ISD::SDIV: > + case ISD::UDIV: > + case ISD::SREM: > + case ISD::UREM: { > > We should expand the list will have to expand to almost all > operators. For example, an ISD::AND or ISD::XOR could cause the > same problem as well as VECTOR_SHUFFLE. > > @@ -326,6 +422,16 @@ > SDValue VectorLegalizer::UnrollVectorOp( > Scalars.push_back(DAG.getNode(Op.getOpcode(), dl, EltVT, > Operands[0], > DAG.getShiftAmountOperand > (Operands[1]))); > break; > + // Ensure that both operands are defined, if not, the result > will > + // be undefined. > + case ISD::SDIV: > + case ISD::UDIV: > > For some machines, SREM and UREM could have the same issue. > > This is a generic issue that goes beyond just SDIV/UDIV. In the > majority of these cases, I think we should try to avoid generating > operations for UNDEF. The only cases that give me pause of doing > this all the time are operations like multiplication by 0, and of 0, > etc.. where the UNDEF would be defined. The only other thing is > that we recursively walk up an expression tree. If the expression > tree is deep, this could cost some time. > > The main culprit that causes these UNDEF is due to widening. A > crazy idea to avoid doing this is if a hardware knows a particular > operation should not be widened, maybe it could use a target hook to > scalarize the operation early doing LegalizeTypes. For X86, since > divides will not be vector operations, we would avoid widening them > only to lower them and work hard trying to avoid generating the > extra divides. > > -- Mon Ping > > > On Nov 6, 2009, at 1:39 PM, Sjodin, Jan wrote: > >> In LegalizeVectorOps the resulting scalar divisions must not be >> generated if they have undefined vector elements as operands. This >> may >> be unsafe because the divides can cause division by zero exceptions, >> and also slows down the code. This patch attempts to fix this issue >> by >> checking if the operands are defined or not. I would be grateful if >> someone could review this patch. Thanks! >> >> - Jan >> Sjodin >> < >> 0015_scalarized_div.diff >> >_______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/84c9df7c/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: scalar_widen.patch Type: application/octet-stream Size: 5886 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/84c9df7c/attachment.obj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/84c9df7c/attachment-0001.html From benny.kra at googlemail.com Thu Nov 12 06:35:27 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 12 Nov 2009 12:35:27 -0000 Subject: [llvm-commits] [llvm] r86984 - /llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Message-ID: <200911121235.nACCZR5A020080@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 12 06:35:27 2009 New Revision: 86984 URL: http://llvm.org/viewvc/llvm-project?rev=86984&view=rev Log: Fix typo in run line. Modified: llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Modified: llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll?rev=86984&r1=86983&r2=86984&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2009-11-11-ScavengerAssert.ll Thu Nov 12 06:35:27 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriplethumbv7-apple-darwin10 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 %struct.OP = type { %struct.OP*, %struct.OP*, %struct.OP* ()*, i32, i16, i16, i8, i8 } %struct.SV = type { i8*, i32, i32 } From espindola at google.com Thu Nov 12 08:09:10 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 12 Nov 2009 09:09:10 -0500 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> Message-ID: <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> > Probably not. The way gcc does this is by having each major > subdirectory have a configure script that run by make. We could also > try to allow projects to have macros that are included at configure > creation time. ?The second option avoids having a second annoying > configure script in the build ... Or we could switch to cmake :-) What are the missing features of the cmake based build system? It looks easier to handle config.h generation in cmake than in autoconf. Does cmake support non-recursive makes? Not that we use one for llvm now, but it is nice not to drop the possibility of doing it. Cheers, -- Rafael ?vila de Esp?ndola From Jan.Sjodin at amd.com Thu Nov 12 08:06:34 2009 From: Jan.Sjodin at amd.com (Sjodin, Jan) Date: Thu, 12 Nov 2009 06:06:34 -0800 Subject: [llvm-commits] Patch for scalarized division. In-Reply-To: <4216CF46-9567-4652-826C-EF51AE9BFEC7@apple.com> References: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> <1C8DE0332CB01445BF7ADEDE3DDD57071958D1D1@sausexmbp02.amd.com>, <4216CF46-9567-4652-826C-EF51AE9BFEC7@apple.com> Message-ID: <1C8DE0332CB01445BF7ADEDE3DDD570718B2A1AA@sausexmbp02.amd.com> This looks a lot better. I will try this patch. Thanks, Jan ________________________________________ From: Mon Ping Wang [wangmp at apple.com] Sent: Thursday, November 12, 2009 4:11 AM To: Sjodin, Jan Cc: 'llvm-commits at cs.uiuc.edu' Subject: Re: [llvm-commits] Patch for scalarized division. Hi, We use to have a design where LegalizeOp did both type legalization and operation legalization. The problem with that approach was that after type legalization, there were opportunities for dag combiner to cleanup code and if it was one phase, we would miss these optimizations or have to teach legalization the optimizations that dag combiner has. Here is a patch for an alternative approach based on using the custom lowering hook. The default widening algorithm doesn't know if an operation doesn't have a vector equivalent nor if the operation can trap since this is target dependent. For these cases, widen will want to scalarize the operation and rebuild the vector and add any undefs at the end for the widen vector. This avoids generating the operation on undef. The patch adds the custom lowering node hook to Widening in Type Legalization. In the target machine, for any vector divide/remainder operation that we would need to widen (i.e., vectors of illegal types), we would call the custom widen operation which does the above. I need to add a few test cases but it does fix the case you gave in your example. Please let me know what you think. -- Mon Ping From anton at korobeynikov.info Thu Nov 12 08:26:19 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 12 Nov 2009 17:26:19 +0300 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> Message-ID: > What are the missing features of the cmake based build system? Does cmake build system support cross-compilation? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From nunoplopes at sapo.pt Thu Nov 12 08:53:53 2009 From: nunoplopes at sapo.pt (Nuno Lopes) Date: Thu, 12 Nov 2009 14:53:53 -0000 Subject: [llvm-commits] [llvm] r86986 - in /llvm/trunk: include/llvm/Support/ConstantRange.h lib/Support/ConstantRange.cpp Message-ID: <200911121453.nACErrqC025441@zion.cs.uiuc.edu> Author: nlopes Date: Thu Nov 12 08:53:53 2009 New Revision: 86986 URL: http://llvm.org/viewvc/llvm-project?rev=86986&view=rev Log: implement shl, ashr, and lshr methods. shl is not fully implemented as it is quite tricky. Modified: llvm/trunk/include/llvm/Support/ConstantRange.h llvm/trunk/lib/Support/ConstantRange.cpp Modified: llvm/trunk/include/llvm/Support/ConstantRange.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantRange.h?rev=86986&r1=86985&r2=86986&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantRange.h (original) +++ llvm/trunk/include/llvm/Support/ConstantRange.h Thu Nov 12 08:53:53 2009 @@ -217,6 +217,18 @@ /// TODO: This isn't fully implemented yet. ConstantRange udiv(const ConstantRange &Other) const; + /// shl - Return a new range representing the possible values resulting + /// from a left shift of a value in this range by the Amount value. + ConstantRange shl(const ConstantRange &Amount) const; + + /// ashr - Return a new range representing the possible values resulting from + /// an arithmetic right shift of a value in this range by the Amount value. + ConstantRange ashr(const ConstantRange &Amount) const; + + /// shr - Return a new range representing the possible values resulting + /// from a logical right shift of a value in this range by the Amount value. + ConstantRange lshr(const ConstantRange &Amount) const; + /// print - Print out the bounds to a stream... /// void print(raw_ostream &OS) const; Modified: llvm/trunk/lib/Support/ConstantRange.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=86986&r1=86985&r2=86986&view=diff ============================================================================== --- llvm/trunk/lib/Support/ConstantRange.cpp (original) +++ llvm/trunk/lib/Support/ConstantRange.cpp Thu Nov 12 08:53:53 2009 @@ -609,6 +609,43 @@ return ConstantRange(Lower, Upper); } +ConstantRange +ConstantRange::shl(const ConstantRange &Amount) const { + if (isEmptySet()) + return *this; + + APInt min = getUnsignedMin() << Amount.getUnsignedMin(); + APInt max = getUnsignedMax() << Amount.getUnsignedMax(); + + // there's no overflow! + APInt Zeros(sizeof(unsigned)*8, getUnsignedMax().countLeadingZeros()); + if (Zeros.uge(Amount.getUnsignedMax())) + return ConstantRange(min, max); + + // FIXME: implement the other tricky cases + return ConstantRange(getBitWidth()); +} + +ConstantRange +ConstantRange::ashr(const ConstantRange &Amount) const { + if (isEmptySet()) + return *this; + + APInt min = getUnsignedMax().ashr(Amount.getUnsignedMin()); + APInt max = getUnsignedMin().ashr(Amount.getUnsignedMax()); + return ConstantRange(min, max); +} + +ConstantRange +ConstantRange::lshr(const ConstantRange &Amount) const { + if (isEmptySet()) + return *this; + + APInt min = getUnsignedMax().lshr(Amount.getUnsignedMin()); + APInt max = getUnsignedMin().lshr(Amount.getUnsignedMax()); + return ConstantRange(min, max); +} + /// print - Print out the bounds to a stream... /// void ConstantRange::print(raw_ostream &OS) const { From ofv at wanadoo.es Thu Nov 12 09:03:10 2009 From: ofv at wanadoo.es (=?windows-1252?Q?=D3scar_Fuentes?=) Date: Thu, 12 Nov 2009 16:03:10 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> Message-ID: <87aayr6b0x.fsf@telefonica.net> Anton Korobeynikov writes: >> What are the missing features of the cmake based build system? > Does cmake build system support cross-compilation? Yup. I ussually build LLVM on Linux with MinGW cross-compiler. See http://www.llvm.org/docs/CMake.html#cross It is simpler than it seems :-) -- ?scar From nunoplopes at sapo.pt Thu Nov 12 09:10:33 2009 From: nunoplopes at sapo.pt (Nuno Lopes) Date: Thu, 12 Nov 2009 15:10:33 -0000 Subject: [llvm-commits] [llvm] r86987 - /llvm/trunk/lib/Support/ConstantRange.cpp Message-ID: <200911121510.nACFAXf6026160@zion.cs.uiuc.edu> Author: nlopes Date: Thu Nov 12 09:10:33 2009 New Revision: 86987 URL: http://llvm.org/viewvc/llvm-project?rev=86987&view=rev Log: fix crash in my previous patch Modified: llvm/trunk/lib/Support/ConstantRange.cpp Modified: llvm/trunk/lib/Support/ConstantRange.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=86987&r1=86986&r2=86987&view=diff ============================================================================== --- llvm/trunk/lib/Support/ConstantRange.cpp (original) +++ llvm/trunk/lib/Support/ConstantRange.cpp Thu Nov 12 09:10:33 2009 @@ -618,7 +618,7 @@ APInt max = getUnsignedMax() << Amount.getUnsignedMax(); // there's no overflow! - APInt Zeros(sizeof(unsigned)*8, getUnsignedMax().countLeadingZeros()); + APInt Zeros(getBitWidth(), getUnsignedMax().countLeadingZeros()); if (Zeros.uge(Amount.getUnsignedMax())) return ConstantRange(min, max); From ofv at wanadoo.es Thu Nov 12 09:20:10 2009 From: ofv at wanadoo.es (=?windows-1252?Q?=D3scar_Fuentes?=) Date: Thu, 12 Nov 2009 16:20:10 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> Message-ID: <87639f6a8l.fsf@telefonica.net> Rafael Espindola writes: >> Probably not. The way gcc does this is by having each major >> subdirectory have a configure script that run by make. We could also >> try to allow projects to have macros that are included at configure >> creation time. ?The second option avoids having a second annoying >> configure script in the build ... > > Or we could switch to cmake :-) That would make a lot of sense, but as my skin is not bullet-proof, I will not be the first one making the proposal on llvm-dev :-) > What are the missing features of the cmake based build system? Now that testing works, there is no major feature missing, AFAIK. configure has some extra knobs, but those can be easily implemented on cmake. > It looks easier to handle config.h generation in cmake than in > autoconf. > > Does cmake support non-recursive makes? Not that we use one for llvm > now, but it is nice not to drop the possibility of doing it. You shouldn't care about how the inners of cmake work. Specifically, the user is advised to *not* look at the makefiles. So far my experience indicates that performance is similar to the configure build, and having dependencies right is quite easy, given the complexity of the LLVM build. Maintenance of the cmake LLVM build system is easier than maintaining the old single Makefile that my compiler project used, and that only provided support for 6 compilers on 2 platforms. -- ?scar From daniel at zuster.org Thu Nov 12 09:42:01 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 07:42:01 -0800 Subject: [llvm-commits] [llvm] r86941 - in /llvm/trunk: lib/ExecutionEngine/JIT/JITEmitter.cpp unittests/ExecutionEngine/JIT/JITTest.cpp In-Reply-To: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> References: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> Message-ID: <6a8523d60911120742y5e15e837x2573e33be18fb2bb@mail.gmail.com> Hi Eric, This test: LLVM-Unit::ExecutionEngine/JIT/Debug/JITTests/JITTest.FarCallToKnownFunction appears to be failing with this change, on linux and x86_64. Can you take a look? - Daniel On Wed, Nov 11, 2009 at 7:12 PM, Eric Christopher wrote: > Author: echristo > Date: Wed Nov 11 21:12:18 2009 > New Revision: 86941 > > URL: http://llvm.org/viewvc/llvm-project?rev=86941&view=rev > Log: > Use stubs when we have them, otherwise use code we already have, > otherwise create a stub. > > Add a test to make sure we don't create extraneous stubs. > > Modified: > ? ?llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp > ? ?llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > > Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86941&r1=86940&r2=86941&view=diff > > ============================================================================== > --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) > +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Wed Nov 11 21:12:18 2009 > @@ -225,7 +225,7 @@ > ? ? ? assert(TheJITResolver == 0 && "Multiple JIT resolvers?"); > ? ? ? TheJITResolver = this; > ? ? } > - > + > ? ? ~JITResolver() { > ? ? ? TheJITResolver = 0; > ? ? } > @@ -256,10 +256,10 @@ > ? ? ? state.AddCallSite(locked, Location, F); > ? ? ? return (void*)(intptr_t)LazyResolverFn; > ? ? } > - > + > ? ? void getRelocatableGVs(SmallVectorImpl &GVs, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?SmallVectorImpl &Ptrs); > - > + > ? ? GlobalValue *invalidateStub(void *Stub); > > ? ? /// getGOTIndexForAddress - Return a new or existing index in the GOT for > @@ -291,7 +291,7 @@ > ? ? /// Relocations - These are the relocations that the function needs, as > ? ? /// emitted. > ? ? std::vector Relocations; > - > + > ? ? /// MBBLocations - This vector is a mapping from MBB ID's to their address. > ? ? /// It is filled in by the StartMachineBasicBlock callback and queried by > ? ? /// the getMachineBasicBlockAddress callback. > @@ -312,7 +312,7 @@ > ? ? /// JumpTable - The jump tables for the current function. > ? ? /// > ? ? MachineJumpTableInfo *JumpTable; > - > + > ? ? /// JumpTableBase - A pointer to the first entry in the jump table. > ? ? /// > ? ? void *JumpTableBase; > @@ -326,7 +326,7 @@ > ? ? /// DR - The debug registerer for the jit. > ? ? OwningPtr DR; > > - ? ?/// LabelLocations - This vector is a mapping from Label ID's to their > + ? ?/// LabelLocations - This vector is a mapping from Label ID's to their > ? ? /// address. > ? ? std::vector LabelLocations; > > @@ -336,7 +336,7 @@ > ? ? // GVSet - a set to keep track of which globals have been seen > ? ? SmallPtrSet GVSet; > > - ? ?// CurFn - The llvm function being emitted. ?Only valid during > + ? ?// CurFn - The llvm function being emitted. ?Only valid during > ? ? // finishFunction(). > ? ? const Function *CurFn; > > @@ -368,7 +368,7 @@ > ? ? // reference the stub. ?When the count of a stub's references drops to zero, > ? ? // the stub is unused. > ? ? DenseMap > StubFnRefs; > - > + > ? ? DebugLocTuple PrevDLT; > > ? public: > @@ -388,7 +388,7 @@ > ? ? ? ? DR.reset(new JITDebugRegisterer(TM)); > ? ? ? } > ? ? } > - ? ?~JITEmitter() { > + ? ?~JITEmitter() { > ? ? ? delete MemMgr; > ? ? } > > @@ -397,16 +397,16 @@ > ? ? /// > ? ? static inline bool classof(const JITEmitter*) { return true; } > ? ? static inline bool classof(const MachineCodeEmitter*) { return true; } > - > + > ? ? JITResolver &getJITResolver() { return Resolver; } > > ? ? virtual void startFunction(MachineFunction &F); > ? ? virtual bool finishFunction(MachineFunction &F); > - > + > ? ? void emitConstantPool(MachineConstantPool *MCP); > ? ? void initJumpTableInfo(MachineJumpTableInfo *MJTI); > ? ? void emitJumpTableInfo(MachineJumpTableInfo *MJTI); > - > + > ? ? virtual void startGVStub(const GlobalValue* GV, unsigned StubSize, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Alignment = 1); > ? ? virtual void startGVStub(const GlobalValue* GV, void *Buffer, > @@ -425,7 +425,7 @@ > ? ? virtual void addRelocation(const MachineRelocation &MR) { > ? ? ? Relocations.push_back(MR); > ? ? } > - > + > ? ? virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { > ? ? ? if (MBBLocations.size() <= (unsigned)MBB->getNumber()) > ? ? ? ? MBBLocations.resize((MBB->getNumber()+1)*2); > @@ -438,7 +438,7 @@ > ? ? virtual uintptr_t getJumpTableEntryAddress(unsigned Entry) const; > > ? ? virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { > - ? ? ?assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > + ? ? ?assert(MBBLocations.size() > (unsigned)MBB->getNumber() && > ? ? ? ? ? ? ?MBBLocations[MBB->getNumber()] && "MBB not emitted!"); > ? ? ? return MBBLocations[MBB->getNumber()]; > ? ? } > @@ -456,7 +456,7 @@ > ? ? /// using the stub at the specified address. Allows > ? ? /// deallocateMemForFunction to also remove stubs no longer referenced. > ? ? void AddStubToCurrentFunction(void *Stub); > - > + > ? ? virtual void processDebugLoc(DebugLoc DL, bool BeforePrintingInsn); > > ? ? virtual void emitLabel(uint64_t LabelID) { > @@ -466,11 +466,11 @@ > ? ? } > > ? ? virtual uintptr_t getLabelAddress(uint64_t LabelID) const { > - ? ? ?assert(LabelLocations.size() > (unsigned)LabelID && > + ? ? ?assert(LabelLocations.size() > (unsigned)LabelID && > ? ? ? ? ? ? ?LabelLocations[LabelID] && "Label not emitted!"); > ? ? ? return LabelLocations[LabelID]; > ? ? } > - > + > ? ? virtual void setModuleInfo(MachineModuleInfo* Info) { > ? ? ? MMI = Info; > ? ? ? if (DE.get()) DE->setModuleInfo(Info); > @@ -479,7 +479,7 @@ > ? ? void setMemoryExecutable() { > ? ? ? MemMgr->setMemoryExecutable(); > ? ? } > - > + > ? ? JITMemoryManager *getMemMgr() const { return MemMgr; } > > ? private: > @@ -573,7 +573,7 @@ > ? IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, GVAddress, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JE); > > - ?DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym > + ?DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym > ? ? ? ? << "] for GV '" << GV->getName() << "'\n"); > > ? return IndirectSym; > @@ -607,10 +607,10 @@ > ?void JITResolver::getRelocatableGVs(SmallVectorImpl &GVs, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SmallVectorImpl &Ptrs) { > ? MutexGuard locked(TheJIT->lock); > - > + > ? const FunctionToStubMapTy &FM = state.getFunctionToStubMap(locked); > ? GlobalToIndirectSymMapTy &GM = state.getGlobalToIndirectSymMap(locked); > - > + > ? for (FunctionToStubMapTy::const_iterator i = FM.begin(), e = FM.end(); > ? ? ? ?i != e; ++i){ > ? ? Function *F = i->first; > @@ -646,7 +646,7 @@ > ? ? GM.erase(i); > ? ? return GV; > ? } > - > + > ? // Lastly, check to see if it's in the ExternalFnToStubMap. > ? for (std::map::iterator i = ExternalFnToStubMap.begin(), > ? ? ? ?e = ExternalFnToStubMap.end(); i != e; ++i) { > @@ -655,7 +655,7 @@ > ? ? ExternalFnToStubMap.erase(i); > ? ? break; > ? } > - > + > ? return 0; > ?} > > @@ -664,7 +664,7 @@ > ?/// it if necessary, then returns the resultant function pointer. > ?void *JITResolver::JITCompilerFn(void *Stub) { > ? JITResolver &JR = *TheJITResolver; > - > + > ? Function* F = 0; > ? void* ActualPtr = 0; > > @@ -684,16 +684,16 @@ > > ? // If we have already code generated the function, just return the address. > ? void *Result = TheJIT->getPointerToGlobalIfAvailable(F); > - > + > ? if (!Result) { > ? ? // Otherwise we don't have it, do lazy compilation now. > - > + > ? ? // If lazy compilation is disabled, emit a useful error message and abort. > ? ? if (!TheJIT->isCompilingLazily()) { > ? ? ? llvm_report_error("LLVM JIT requested to do lazy compilation of function '" > ? ? ? ? ? ? ? ? ? ? ? ? + F->getName() + "' when lazy compiles are disabled!"); > ? ? } > - > + > ? ? DEBUG(errs() << "JIT: Lazily resolving function '" << F->getName() > ? ? ? ? ? << "' In stub ptr = " << Stub << " actual ptr = " > ? ? ? ? ? << ActualPtr << "\n"); > @@ -736,15 +736,18 @@ > > ? // If we have already compiled the function, return a pointer to its body. > ? Function *F = cast(V); > - ?void *ResultPtr; > - ?if (MayNeedFarStub) { > - ? ?// Return the function stub if it's already created. > - ? ?ResultPtr = Resolver.getFunctionStubIfAvailable(F); > - ? ?if (ResultPtr) > - ? ? ?AddStubToCurrentFunction(ResultPtr); > - ?} else { > - ? ?ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); > + > + ?void *FnStub = Resolver.getFunctionStubIfAvailable(F); > + ?if (FnStub) { > + ? ?// Return the function stub if it's already created. ?We do this first > + ? ?// so that we're returning the same address for the function as any > + ? ?// previous call. > + ? ?AddStubToCurrentFunction(FnStub); > + ? ?return FnStub; > ? } > + > + ?// Otherwise if we have code, go ahead and return that. > + ?void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); > ? if (ResultPtr) return ResultPtr; > > ? // If this is an external function pointer, we can force the JIT to > @@ -778,11 +781,11 @@ > ? // resolved address. > ? void *GVAddress = getPointerToGlobal(V, Reference, false); > ? void *StubAddr = Resolver.getGlobalValueIndirectSym(V, GVAddress); > - > + > ? // Add the stub to the current function's list of referenced stubs, so we can > ? // deallocate them if the current function is ever freed. > ? AddStubToCurrentFunction(StubAddr); > - > + > ? return StubAddr; > ?} > > @@ -807,7 +810,7 @@ > ? ? ? ? NextLine.Loc = DL; > ? ? ? ? EmissionDetails.LineStarts.push_back(NextLine); > ? ? ? } > - > + > ? ? ? PrevDLT = CurDLT; > ? ? } > ? } > @@ -832,7 +835,7 @@ > ?static unsigned GetJumpTableSizeInBytes(MachineJumpTableInfo *MJTI) { > ? const std::vector &JT = MJTI->getJumpTables(); > ? if (JT.empty()) return 0; > - > + > ? unsigned NumEntries = 0; > ? for (unsigned i = 0, e = JT.size(); i != e; ++i) > ? ? NumEntries += JT[i].MBBs.size(); > @@ -844,7 +847,7 @@ > > ?static uintptr_t RoundUpToAlign(uintptr_t Size, unsigned Alignment) { > ? if (Alignment == 0) Alignment = 1; > - ?// Since we do not know where the buffer will be allocated, be pessimistic. > + ?// Since we do not know where the buffer will be allocated, be pessimistic. > ? return Size + Alignment; > ?} > > @@ -854,7 +857,7 @@ > ?unsigned JITEmitter::addSizeOfGlobal(const GlobalVariable *GV, unsigned Size) { > ? const Type *ElTy = GV->getType()->getElementType(); > ? size_t GVSize = (size_t)TheJIT->getTargetData()->getTypeAllocSize(ElTy); > - ?size_t GVAlign = > + ?size_t GVAlign = > ? ? ? (size_t)TheJIT->getTargetData()->getPreferredAlignment(GV); > ? DEBUG(errs() << "JIT: Adding in size " << GVSize << " alignment " << GVAlign); > ? DEBUG(GV->dump()); > @@ -871,7 +874,7 @@ > ?/// but are referenced from the constant; put them in GVSet and add their > ?/// size into the running total Size. > > -unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C, > +unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Size) { > ? // If its undefined, return the garbage. > ? if (isa(C)) > @@ -934,7 +937,7 @@ > ?/// addSizeOfGLobalsInInitializer - handle any globals that we haven't seen yet > ?/// but are referenced from the given initializer. > > -unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant *Init, > +unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant *Init, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Size) { > ? if (!isa(Init) && > ? ? ? !isa(Init) && > @@ -955,7 +958,7 @@ > ? unsigned Size = 0; > ? GVSet.clear(); > > - ?for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); > + ?for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); > ? ? ? ?MBB != E; ++MBB) { > ? ? for (MachineBasicBlock::const_iterator I = MBB->begin(), E = MBB->end(); > ? ? ? ? ?I != E; ++I) { > @@ -987,7 +990,7 @@ > ? DEBUG(errs() << "JIT: About to look through initializers\n"); > ? // Look for more globals that are referenced only from initializers. > ? // GVSet.end is computed each time because the set can grow as we go. > - ?for (SmallPtrSet::iterator I = GVSet.begin(); > + ?for (SmallPtrSet::iterator I = GVSet.begin(); > ? ? ? ?I != GVSet.end(); I++) { > ? ? const GlobalVariable* GV = *I; > ? ? if (GV->hasInitializer()) > @@ -1009,10 +1012,10 @@ > ? ? const TargetInstrInfo* TII = F.getTarget().getInstrInfo(); > ? ? MachineJumpTableInfo *MJTI = F.getJumpTableInfo(); > ? ? MachineConstantPool *MCP = F.getConstantPool(); > - > + > ? ? // Ensure the constant pool/jump table info is at least 4-byte aligned. > ? ? ActualSize = RoundUpToAlign(ActualSize, 16); > - > + > ? ? // Add the alignment of the constant pool > ? ? ActualSize = RoundUpToAlign(ActualSize, MCP->getConstantPoolAlignment()); > > @@ -1024,7 +1027,7 @@ > > ? ? // Add the jump table size > ? ? ActualSize += GetJumpTableSizeInBytes(MJTI); > - > + > ? ? // Add the alignment for the function > ? ? ActualSize = RoundUpToAlign(ActualSize, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::max(F.getFunction()->getAlignment(), 8U)); > @@ -1097,7 +1100,7 @@ > ? ? ? ? ? ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false); > ? ? ? ? ? DEBUG(errs() << "JIT: Map \'" << MR.getExternalSymbol() << "\' to [" > - ? ? ? ? ? ? ? ? ? ? ? << ResultPtr << "]\n"); > + ? ? ? ? ? ? ? ? ? ? ? << ResultPtr << "]\n"); > > ? ? ? ? ? // If the target REALLY wants a stub for this function, emit it now. > ? ? ? ? ? if (MR.mayNeedFarStub()) { > @@ -1255,7 +1258,7 @@ > > ? if (MMI) > ? ? MMI->EndFunction(); > - > + > ? return false; > ?} > > @@ -1293,20 +1296,20 @@ > ? // If the function did not reference any stubs, return. > ? if (CurFnStubUses.find(F) == CurFnStubUses.end()) > ? ? return; > - > + > ? // For each referenced stub, erase the reference to this function, and then > ? // erase the list of referenced stubs. > ? SmallVectorImpl &StubList = CurFnStubUses[F]; > ? for (unsigned i = 0, e = StubList.size(); i != e; ++i) { > ? ? void *Stub = StubList[i]; > - > + > ? ? // If we already invalidated this stub for this function, continue. > ? ? if (StubFnRefs.count(Stub) == 0) > ? ? ? continue; > - > + > ? ? SmallPtrSet &FnRefs = StubFnRefs[Stub]; > ? ? FnRefs.erase(F); > - > + > ? ? // If this function was the last reference to the stub, invalidate the stub > ? ? // in the JITResolver. ?Were there a memory manager deallocateStub routine, > ? ? // we could call that at this point too. > @@ -1389,7 +1392,7 @@ > > ? const std::vector &JT = MJTI->getJumpTables(); > ? if (JT.empty()) return; > - > + > ? unsigned NumEntries = 0; > ? for (unsigned i = 0, e = JT.size(); i != e; ++i) > ? ? NumEntries += JT[i].MBBs.size(); > @@ -1409,7 +1412,7 @@ > > ? const std::vector &JT = MJTI->getJumpTables(); > ? if (JT.empty() || JumpTableBase == 0) return; > - > + > ? if (TargetMachine::getRelocationModel() == Reloc::PIC_) { > ? ? assert(MJTI->getEntrySize() == 4 && "Cross JIT'ing?"); > ? ? // For each jump table, place the offset from the beginning of the table > @@ -1428,8 +1431,8 @@ > ? ? } > ? } else { > ? ? assert(MJTI->getEntrySize() == sizeof(void*) && "Cross JIT'ing?"); > - > - ? ?// For each jump table, map each target in the jump table to the address of > + > + ? ?// For each jump table, map each target in the jump table to the address of > ? ? // an emitted MachineBasicBlock. > ? ? intptr_t *SlotPtr = (intptr_t*)JumpTableBase; > > @@ -1448,7 +1451,7 @@ > ? SavedBufferBegin = BufferBegin; > ? SavedBufferEnd = BufferEnd; > ? SavedCurBufferPtr = CurBufferPtr; > - > + > ? BufferBegin = CurBufferPtr = MemMgr->allocateStub(GV, StubSize, Alignment); > ? BufferEnd = BufferBegin+StubSize+1; > ?} > @@ -1458,7 +1461,7 @@ > ? SavedBufferBegin = BufferBegin; > ? SavedBufferEnd = BufferEnd; > ? SavedCurBufferPtr = CurBufferPtr; > - > + > ? BufferBegin = CurBufferPtr = (uint8_t *)Buffer; > ? BufferEnd = BufferBegin+StubSize+1; > ?} > @@ -1487,15 +1490,15 @@ > ?uintptr_t JITEmitter::getJumpTableEntryAddress(unsigned Index) const { > ? const std::vector &JT = JumpTable->getJumpTables(); > ? assert(Index < JT.size() && "Invalid jump table index!"); > - > + > ? unsigned Offset = 0; > ? unsigned EntrySize = JumpTable->getEntrySize(); > - > + > ? for (unsigned i = 0; i < Index; ++i) > ? ? Offset += JT[i].MBBs.size(); > - > + > ? ?Offset *= EntrySize; > - > + > ? return (uintptr_t)((char *)JumpTableBase + Offset); > ?} > > @@ -1540,7 +1543,7 @@ > ? // If we have already code generated the function, just return the address. > ? if (void *Addr = getPointerToGlobalIfAvailable(F)) > ? ? return Addr; > - > + > ? // Get a stub if the target supports it. > ? assert(isa(JCE) && "Unexpected MCE?"); > ? JITEmitter *JE = cast(getCodeEmitter()); > > Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=86941&r1=86940&r2=86941&view=diff > > ============================================================================== > --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) > +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Wed Nov 11 21:12:18 2009 > @@ -61,6 +61,7 @@ > ?public: > ? RecordingJITMemoryManager() > ? ? : Base(JITMemoryManager::CreateDefaultMemManager()) { > + ? ?stubsAllocated = 0; > ? } > > ? virtual void setMemoryWritable() { Base->setMemoryWritable(); } > @@ -88,8 +89,10 @@ > ? ? ? StartFunctionBodyCall(Result, F, InitialActualSize, ActualSize)); > ? ? return Result; > ? } > + ?int stubsAllocated; > ? virtual uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Alignment) { > + ? ?stubsAllocated++; > ? ? return Base->allocateStub(F, StubSize, Alignment); > ? } > ? struct EndFunctionBodyCall { > @@ -455,6 +458,44 @@ > ? ? ? ? ? ? NumTablesDeallocated); > ?} > > +typedef int (*FooPtr) (); > + > +TEST_F(JITTest, NoStubs) { > + ?LoadAssembly("define void @bar() {" > + ? ? ? ? ? ? ?"entry: " > + ? ? ? ? ? ? ?"ret void" > + ? ? ? ? ? ? ?"}" > + ? ? ? ? ? ? ?" " > + ? ? ? ? ? ? ?"define i32 @foo() {" > + ? ? ? ? ? ? ?"entry:" > + ? ? ? ? ? ? ?"call void @bar()" > + ? ? ? ? ? ? ?"ret i32 undef" > + ? ? ? ? ? ? ?"}" > + ? ? ? ? ? ? ?" " > + ? ? ? ? ? ? ?"define i32 @main() {" > + ? ? ? ? ? ? ?"entry:" > + ? ? ? ? ? ? ?"%0 = call i32 @foo()" > + ? ? ? ? ? ? ?"call void @bar()" > + ? ? ? ? ? ? ?"ret i32 undef" > + ? ? ? ? ? ? ?"}"); > + ?Function *foo = M->getFunction("foo"); > + ?uintptr_t tmp = (uintptr_t)(TheJIT->getPointerToFunction(foo)); > + ?FooPtr ptr = (FooPtr)(tmp); > + > + ?(ptr)(); > + > + ?// We should now allocate no more stubs, we have the code to foo > + ?// and the existing stub for bar. > + ?int stubsBefore = RJMM->stubsAllocated; > + ?Function *func = M->getFunction("main"); > + ?TheJIT->getPointerToFunction(func); > + > + ?Function *bar = M->getFunction("bar"); > + ?TheJIT->getPointerToFunction(bar); > + > + ?ASSERT_EQ(stubsBefore, RJMM->stubsAllocated); > +} > + > ?// This code is copied from JITEventListenerTest, but it only runs once for all > ?// the tests in this directory. ?Everything seems fine, but that's strange > ?// behavior. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From criswell at uiuc.edu Thu Nov 12 10:09:10 2009 From: criswell at uiuc.edu (John Criswell) Date: Thu, 12 Nov 2009 16:09:10 -0000 Subject: [llvm-commits] [poolalloc] r86991 - in /poolalloc/branches/SVA: include/dsa/DSNode.h lib/DSA/Local.cpp lib/DSA/TopDownClosure.cpp Message-ID: <200911121609.nACG9ABM028186@zion.cs.uiuc.edu> Author: criswell Date: Thu Nov 12 10:09:09 2009 New Revision: 86991 URL: http://llvm.org/viewvc/llvm-project?rev=86991&view=rev Log: Added code to the TopDown pass to signal to SAFECode/SVA that a pointer needs a run-time check because values from the same kernel pool (kmem_cache_t in Linux) return values of different types. Added code to handle the llva_do_index instruction. Modified: poolalloc/branches/SVA/include/dsa/DSNode.h poolalloc/branches/SVA/lib/DSA/Local.cpp poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp Modified: poolalloc/branches/SVA/include/dsa/DSNode.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/include/dsa/DSNode.h?rev=86991&r1=86990&r2=86991&view=diff ============================================================================== --- poolalloc/branches/SVA/include/dsa/DSNode.h (original) +++ poolalloc/branches/SVA/include/dsa/DSNode.h Thu Nov 12 10:09:09 2009 @@ -159,8 +159,9 @@ Array = 1 << 7, // This node is treated like an array External = 1 << 8, // This node comes from an external source IONode = 1 << 9, // This node comes from an external source + CheckAnyway = 1 << 10, // This node may be type-safe but check it anyway //#ifndef NDEBUG - DEAD = 1 << 10, // This node is dead and should not be pointed to + DEAD = 1 << 11, // This node is dead and should not be pointed to //#endif Composition = AllocaNode | HeapNode | GlobalNode | IONode | UnknownNode @@ -421,11 +422,13 @@ bool isDeadNode() const { return NodeType & DEAD; } bool isExternalNode() const { return NodeType & External; } bool isIONode() const { return NodeType & IONode; } + bool isCheckAnyway() const { return NodeType & CheckAnyway; } DSNode *setAllocaNodeMarker() { NodeType |= AllocaNode; return this; } DSNode *setHeapNodeMarker() { NodeType |= HeapNode; return this; } DSNode *setGlobalNodeMarker() { NodeType |= GlobalNode; return this; } DSNode *setIONodeMarker() { NodeType |= IONode; return this; } + DSNode *setCheckAnywayNodeMarker() { NodeType |= CheckAnyway; return this; } DSNode *setUnknownNodeMarker(); // { ++stat_unknown; NodeType |= UnknownNode; return this; } DSNode *setExternalMarker() { NodeType |= External; return this; } Modified: poolalloc/branches/SVA/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/Local.cpp?rev=86991&r1=86990&r2=86991&view=diff ============================================================================== --- poolalloc/branches/SVA/lib/DSA/Local.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/Local.cpp Thu Nov 12 10:09:09 2009 @@ -312,6 +312,16 @@ } else { goto fail; } +#ifdef LLVA_KERNEL + } else if (CallInst * CI = dyn_cast(V)) { + Function * F = CI->getCalledFunction(); + if (!F) goto fail; + if ((F->hasName()) && (F->getName() == "llva_do_index")) { + tocheck.push(CI->getOperand(1)); + } else { + goto fail; + } +#endif } else { goto fail; } Modified: poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp?rev=86991&r1=86990&r2=86991&view=diff ============================================================================== --- poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp Thu Nov 12 10:09:09 2009 @@ -163,6 +163,68 @@ // same MetaPool. // Function* KMA = M.getNamedFunction("kmem_cache_alloc"); +#if 1 + if (KMA) { + // Map from kmem_cache_t's metapool to the type of values returned from the + // kmem_cache_t + std::map types; + + for (Value::use_iterator ii = KMA->use_begin(), ee = KMA->use_end(); + ii != ee; ++ii) { + CallInst* CI = dyn_cast(*ii); + if ((CI) && (CI->getCalledFunction() == KMA)) { + // Function in which the call statement resides + Function * F = CI->getParent()->getParent(); + + // The pointer to the kmem_cache_t + Value* CacheT = CI->getOperand(1); + + // + // Get the metapool for the kmem_cache_t + // + DSNodeHandle DSCacheT = DSInfo[F]->getNodeForValue(CacheT); + MetaPoolHandle MPCacheT (DSCacheT.getNode()->getMP()); + + // + // Get the DSNode handle of the object being allocated. + // + DSNodeHandle DSH = DSInfo[F]->getNodeForValue(CI); + MetaPoolHandle MPNode (DSH.getNode()->getMP()); + + // + // Ensure that all objects allocated from this kmem_cache_t have the + // same type. + // + if (types[MPCacheT.getPool()].getNode()) { + // + // Get the type of the objects allocated from this kernel pool. + // + const Type * MPType = types[MPCacheT.getPool()].getNode()->getType(); + const Type * OJType = DSH.getNode()->getType(); + + // + // If this allocation site does not allocate objects of the same + // type, then make both DSNodes type-unknown. + // + if (MPType != DSH.getNode()->getType()) { + DSH.getNode()->setCheckAnywayNodeMarker(); + types[MPCacheT.getPool()].getNode()->setCheckAnywayNodeMarker(); + std::cerr << "kmem_cache_alloc: 2: Folded!" << std::endl; + } + } else { + // + // Now DSNode has been associated with objects allocated from this + // kernel pool. Record the first one that we have found. + // + std::cerr << "kmem_cache_alloc: Adding!" << std::endl; + types[MPCacheT.getPool()] = DSH; + } + } + } + } +#endif + +#if 1 if (KMA) { // Map from kmem_cache_t's metapool to the metapool of its return value std::map locs; @@ -203,6 +265,7 @@ } } #endif +#endif return false; } From edwintorok at gmail.com Thu Nov 12 10:39:14 2009 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Thu, 12 Nov 2009 18:39:14 +0200 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> Message-ID: <4AFC3A32.7030607@gmail.com> On 2009-11-12 16:09, Rafael Espindola wrote: >> Probably not. The way gcc does this is by having each major >> subdirectory have a configure script that run by make. We could also >> try to allow projects to have macros that are included at configure >> creation time. The second option avoids having a second annoying >> configure script in the build ... >> > > Or we could switch to cmake :-) > What are the missing features of the cmake based build system? It > looks easier to handle config.h generation in cmake than in autoconf. > > Does cmake support non-recursive makes? Not that we use one for llvm > now, but it is nice not to drop the possibility of doing it.\ > The current Makefiles don't support it either, they only support GNU make. I don't know if cmake does. Best regards, --Edwin From grosbach at apple.com Thu Nov 12 11:19:09 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 Nov 2009 17:19:09 -0000 Subject: [llvm-commits] [llvm] r86997 - /llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Message-ID: <200911121719.nACHJ9PB031556@zion.cs.uiuc.edu> Author: grosbach Date: Thu Nov 12 11:19:09 2009 New Revision: 86997 URL: http://llvm.org/viewvc/llvm-project?rev=86997&view=rev Log: Clean up testcase a bit. Simplify case blocks and adjust switch instruction to not take an undefined value as input. Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll?rev=86997&r1=86996&r2=86997&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Thu Nov 12 11:19:09 2009 @@ -18,7 +18,7 @@ define arm_apcscc i32 @main(i32 %argc, i8** nocapture %argv) nounwind { ; CHECK: main: -; CHECK: tbh +; CHECK: tbb entry: br label %bb42.i @@ -26,7 +26,7 @@ br label %bb40.i bb5.i: ; preds = %bb42.i - %0 = or i32 %_Y_flags.1, 32 ; [#uses=1] + %0 = or i32 %argc, 32 ; [#uses=1] br label %bb40.i bb7.i: ; preds = %bb42.i @@ -66,14 +66,10 @@ unreachable bb40.i: ; preds = %bb42.i, %bb5.i, %bb1.i2 - %_Y_flags.0 = phi i32 [ 0, %bb1.i2 ], [ %0, %bb5.i ], [ %_Y_flags.1, %bb42.i ] ; [#uses=1] - %_Y_eflag.b.0 = phi i1 [ %_Y_eflag.b.1, %bb1.i2 ], [ %_Y_eflag.b.1, %bb5.i ], [ true, %bb42.i ] ; [#uses=1] br label %bb42.i bb42.i: ; preds = %bb40.i, %entry - %_Y_eflag.b.1 = phi i1 [ false, %entry ], [ %_Y_eflag.b.0, %bb40.i ] ; [#uses=2] - %_Y_flags.1 = phi i32 [ 0, %entry ], [ %_Y_flags.0, %bb40.i ] ; [#uses=2] - switch i32 undef, label %bb39.i [ + switch i32 %argc, label %bb39.i [ i32 67, label %bb33.i i32 70, label %bb35.i i32 77, label %bb37.i From echristo at apple.com Thu Nov 12 11:11:58 2009 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Nov 2009 09:11:58 -0800 Subject: [llvm-commits] [llvm] r86941 - in /llvm/trunk: lib/ExecutionEngine/JIT/JITEmitter.cpp unittests/ExecutionEngine/JIT/JITTest.cpp In-Reply-To: <6a8523d60911120742y5e15e837x2573e33be18fb2bb@mail.gmail.com> References: <200911120312.nAC3CJEf019669@zion.cs.uiuc.edu> <6a8523d60911120742y5e15e837x2573e33be18fb2bb@mail.gmail.com> Message-ID: <37B56A63-1F14-4FE5-8DF7-2CEAFF56BB2C@apple.com> Yeah I sent mail to test results last night. I can't duplicate it on my machine in either 32 or 64bit. I asked Jeffrey for a bit of help tracking it down. If you've got a machine in the office that can duplicate it that'd be awesome :) -eric On Nov 12, 2009, at 7:42 AM, Daniel Dunbar wrote: > Hi Eric, > > This test: > LLVM-Unit::ExecutionEngine/JIT/Debug/JITTests/ > JITTest.FarCallToKnownFunction > appears to be failing with this change, on linux and x86_64. Can you > take a look? > > - Daniel > > On Wed, Nov 11, 2009 at 7:12 PM, Eric Christopher > wrote: >> Author: echristo >> Date: Wed Nov 11 21:12:18 2009 >> New Revision: 86941 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86941&view=rev >> Log: >> Use stubs when we have them, otherwise use code we already have, >> otherwise create a stub. >> >> Add a test to make sure we don't create extraneous stubs. >> >> Modified: >> llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp >> llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >> >> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86941&r1=86940&r2=86941&view=diff >> >> === >> === >> === >> ===================================================================== >> --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) >> +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Wed Nov 11 >> 21:12:18 2009 >> @@ -225,7 +225,7 @@ >> assert(TheJITResolver == 0 && "Multiple JIT resolvers?"); >> TheJITResolver = this; >> } >> - >> + >> ~JITResolver() { >> TheJITResolver = 0; >> } >> @@ -256,10 +256,10 @@ >> state.AddCallSite(locked, Location, F); >> return (void*)(intptr_t)LazyResolverFn; >> } >> - >> + >> void getRelocatableGVs(SmallVectorImpl &GVs, >> SmallVectorImpl &Ptrs); >> - >> + >> GlobalValue *invalidateStub(void *Stub); >> >> /// getGOTIndexForAddress - Return a new or existing index in >> the GOT for >> @@ -291,7 +291,7 @@ >> /// Relocations - These are the relocations that the function >> needs, as >> /// emitted. >> std::vector Relocations; >> - >> + >> /// MBBLocations - This vector is a mapping from MBB ID's to >> their address. >> /// It is filled in by the StartMachineBasicBlock callback and >> queried by >> /// the getMachineBasicBlockAddress callback. >> @@ -312,7 +312,7 @@ >> /// JumpTable - The jump tables for the current function. >> /// >> MachineJumpTableInfo *JumpTable; >> - >> + >> /// JumpTableBase - A pointer to the first entry in the jump >> table. >> /// >> void *JumpTableBase; >> @@ -326,7 +326,7 @@ >> /// DR - The debug registerer for the jit. >> OwningPtr DR; >> >> - /// LabelLocations - This vector is a mapping from Label ID's >> to their >> + /// LabelLocations - This vector is a mapping from Label ID's >> to their >> /// address. >> std::vector LabelLocations; >> >> @@ -336,7 +336,7 @@ >> // GVSet - a set to keep track of which globals have been seen >> SmallPtrSet GVSet; >> >> - // CurFn - The llvm function being emitted. Only valid during >> + // CurFn - The llvm function being emitted. Only valid during >> // finishFunction(). >> const Function *CurFn; >> >> @@ -368,7 +368,7 @@ >> // reference the stub. When the count of a stub's references >> drops to zero, >> // the stub is unused. >> DenseMap > StubFnRefs; >> - >> + >> DebugLocTuple PrevDLT; >> >> public: >> @@ -388,7 +388,7 @@ >> DR.reset(new JITDebugRegisterer(TM)); >> } >> } >> - ~JITEmitter() { >> + ~JITEmitter() { >> delete MemMgr; >> } >> >> @@ -397,16 +397,16 @@ >> /// >> static inline bool classof(const JITEmitter*) { return true; } >> static inline bool classof(const MachineCodeEmitter*) { return >> true; } >> - >> + >> JITResolver &getJITResolver() { return Resolver; } >> >> virtual void startFunction(MachineFunction &F); >> virtual bool finishFunction(MachineFunction &F); >> - >> + >> void emitConstantPool(MachineConstantPool *MCP); >> void initJumpTableInfo(MachineJumpTableInfo *MJTI); >> void emitJumpTableInfo(MachineJumpTableInfo *MJTI); >> - >> + >> virtual void startGVStub(const GlobalValue* GV, unsigned >> StubSize, >> unsigned Alignment = 1); >> virtual void startGVStub(const GlobalValue* GV, void *Buffer, >> @@ -425,7 +425,7 @@ >> virtual void addRelocation(const MachineRelocation &MR) { >> Relocations.push_back(MR); >> } >> - >> + >> virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { >> if (MBBLocations.size() <= (unsigned)MBB->getNumber()) >> MBBLocations.resize((MBB->getNumber()+1)*2); >> @@ -438,7 +438,7 @@ >> virtual uintptr_t getJumpTableEntryAddress(unsigned Entry) const; >> >> virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock >> *MBB) const { >> - assert(MBBLocations.size() > (unsigned)MBB->getNumber() && >> + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && >> MBBLocations[MBB->getNumber()] && "MBB not emitted!"); >> return MBBLocations[MBB->getNumber()]; >> } >> @@ -456,7 +456,7 @@ >> /// using the stub at the specified address. Allows >> /// deallocateMemForFunction to also remove stubs no longer >> referenced. >> void AddStubToCurrentFunction(void *Stub); >> - >> + >> virtual void processDebugLoc(DebugLoc DL, bool >> BeforePrintingInsn); >> >> virtual void emitLabel(uint64_t LabelID) { >> @@ -466,11 +466,11 @@ >> } >> >> virtual uintptr_t getLabelAddress(uint64_t LabelID) const { >> - assert(LabelLocations.size() > (unsigned)LabelID && >> + assert(LabelLocations.size() > (unsigned)LabelID && >> LabelLocations[LabelID] && "Label not emitted!"); >> return LabelLocations[LabelID]; >> } >> - >> + >> virtual void setModuleInfo(MachineModuleInfo* Info) { >> MMI = Info; >> if (DE.get()) DE->setModuleInfo(Info); >> @@ -479,7 +479,7 @@ >> void setMemoryExecutable() { >> MemMgr->setMemoryExecutable(); >> } >> - >> + >> JITMemoryManager *getMemMgr() const { return MemMgr; } >> >> private: >> @@ -573,7 +573,7 @@ >> IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, >> GVAddress, >> JE); >> >> - DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym >> + DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym >> << "] for GV '" << GV->getName() << "'\n"); >> >> return IndirectSym; >> @@ -607,10 +607,10 @@ >> void JITResolver::getRelocatableGVs(SmallVectorImpl >> &GVs, >> SmallVectorImpl &Ptrs) { >> MutexGuard locked(TheJIT->lock); >> - >> + >> const FunctionToStubMapTy &FM = state.getFunctionToStubMap(locked); >> GlobalToIndirectSymMapTy &GM = state.getGlobalToIndirectSymMap >> (locked); >> - >> + >> for (FunctionToStubMapTy::const_iterator i = FM.begin(), e = >> FM.end(); >> i != e; ++i){ >> Function *F = i->first; >> @@ -646,7 +646,7 @@ >> GM.erase(i); >> return GV; >> } >> - >> + >> // Lastly, check to see if it's in the ExternalFnToStubMap. >> for (std::map::iterator i = >> ExternalFnToStubMap.begin(), >> e = ExternalFnToStubMap.end(); i != e; ++i) { >> @@ -655,7 +655,7 @@ >> ExternalFnToStubMap.erase(i); >> break; >> } >> - >> + >> return 0; >> } >> >> @@ -664,7 +664,7 @@ >> /// it if necessary, then returns the resultant function pointer. >> void *JITResolver::JITCompilerFn(void *Stub) { >> JITResolver &JR = *TheJITResolver; >> - >> + >> Function* F = 0; >> void* ActualPtr = 0; >> >> @@ -684,16 +684,16 @@ >> >> // If we have already code generated the function, just return >> the address. >> void *Result = TheJIT->getPointerToGlobalIfAvailable(F); >> - >> + >> if (!Result) { >> // Otherwise we don't have it, do lazy compilation now. >> - >> + >> // If lazy compilation is disabled, emit a useful error message >> and abort. >> if (!TheJIT->isCompilingLazily()) { >> llvm_report_error("LLVM JIT requested to do lazy compilation >> of function '" >> + F->getName() + "' when lazy compiles are >> disabled!"); >> } >> - >> + >> DEBUG(errs() << "JIT: Lazily resolving function '" << F->getName >> () >> << "' In stub ptr = " << Stub << " actual ptr = " >> << ActualPtr << "\n"); >> @@ -736,15 +736,18 @@ >> >> // If we have already compiled the function, return a pointer to >> its body. >> Function *F = cast(V); >> - void *ResultPtr; >> - if (MayNeedFarStub) { >> - // Return the function stub if it's already created. >> - ResultPtr = Resolver.getFunctionStubIfAvailable(F); >> - if (ResultPtr) >> - AddStubToCurrentFunction(ResultPtr); >> - } else { >> - ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); >> + >> + void *FnStub = Resolver.getFunctionStubIfAvailable(F); >> + if (FnStub) { >> + // Return the function stub if it's already created. We do >> this first >> + // so that we're returning the same address for the function >> as any >> + // previous call. >> + AddStubToCurrentFunction(FnStub); >> + return FnStub; >> } >> + >> + // Otherwise if we have code, go ahead and return that. >> + void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); >> if (ResultPtr) return ResultPtr; >> >> // If this is an external function pointer, we can force the JIT to >> @@ -778,11 +781,11 @@ >> // resolved address. >> void *GVAddress = getPointerToGlobal(V, Reference, false); >> void *StubAddr = Resolver.getGlobalValueIndirectSym(V, GVAddress); >> - >> + >> // Add the stub to the current function's list of referenced >> stubs, so we can >> // deallocate them if the current function is ever freed. >> AddStubToCurrentFunction(StubAddr); >> - >> + >> return StubAddr; >> } >> >> @@ -807,7 +810,7 @@ >> NextLine.Loc = DL; >> EmissionDetails.LineStarts.push_back(NextLine); >> } >> - >> + >> PrevDLT = CurDLT; >> } >> } >> @@ -832,7 +835,7 @@ >> static unsigned GetJumpTableSizeInBytes(MachineJumpTableInfo >> *MJTI) { >> const std::vector &JT = MJTI->getJumpTables >> (); >> if (JT.empty()) return 0; >> - >> + >> unsigned NumEntries = 0; >> for (unsigned i = 0, e = JT.size(); i != e; ++i) >> NumEntries += JT[i].MBBs.size(); >> @@ -844,7 +847,7 @@ >> >> static uintptr_t RoundUpToAlign(uintptr_t Size, unsigned >> Alignment) { >> if (Alignment == 0) Alignment = 1; >> - // Since we do not know where the buffer will be allocated, be >> pessimistic. >> + // Since we do not know where the buffer will be allocated, be >> pessimistic. >> return Size + Alignment; >> } >> >> @@ -854,7 +857,7 @@ >> unsigned JITEmitter::addSizeOfGlobal(const GlobalVariable *GV, >> unsigned Size) { >> const Type *ElTy = GV->getType()->getElementType(); >> size_t GVSize = (size_t)TheJIT->getTargetData()->getTypeAllocSize >> (ElTy); >> - size_t GVAlign = >> + size_t GVAlign = >> (size_t)TheJIT->getTargetData()->getPreferredAlignment(GV); >> DEBUG(errs() << "JIT: Adding in size " << GVSize << " alignment " >> << GVAlign); >> DEBUG(GV->dump()); >> @@ -871,7 +874,7 @@ >> /// but are referenced from the constant; put them in GVSet and >> add their >> /// size into the running total Size. >> >> -unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant >> *C, >> +unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant >> *C, >> unsigned Size) { >> // If its undefined, return the garbage. >> if (isa(C)) >> @@ -934,7 +937,7 @@ >> /// addSizeOfGLobalsInInitializer - handle any globals that we >> haven't seen yet >> /// but are referenced from the given initializer. >> >> -unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant >> *Init, >> +unsigned JITEmitter::addSizeOfGlobalsInInitializer(const Constant >> *Init, >> unsigned Size) { >> if (!isa(Init) && >> !isa(Init) && >> @@ -955,7 +958,7 @@ >> unsigned Size = 0; >> GVSet.clear(); >> >> - for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); >> + for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); >> MBB != E; ++MBB) { >> for (MachineBasicBlock::const_iterator I = MBB->begin(), E = >> MBB->end(); >> I != E; ++I) { >> @@ -987,7 +990,7 @@ >> DEBUG(errs() << "JIT: About to look through initializers\n"); >> // Look for more globals that are referenced only from >> initializers. >> // GVSet.end is computed each time because the set can grow as we >> go. >> - for (SmallPtrSet::iterator I = >> GVSet.begin(); >> + for (SmallPtrSet::iterator I = >> GVSet.begin(); >> I != GVSet.end(); I++) { >> const GlobalVariable* GV = *I; >> if (GV->hasInitializer()) >> @@ -1009,10 +1012,10 @@ >> const TargetInstrInfo* TII = F.getTarget().getInstrInfo(); >> MachineJumpTableInfo *MJTI = F.getJumpTableInfo(); >> MachineConstantPool *MCP = F.getConstantPool(); >> - >> + >> // Ensure the constant pool/jump table info is at least 4-byte >> aligned. >> ActualSize = RoundUpToAlign(ActualSize, 16); >> - >> + >> // Add the alignment of the constant pool >> ActualSize = RoundUpToAlign(ActualSize, MCP- >> >getConstantPoolAlignment()); >> >> @@ -1024,7 +1027,7 @@ >> >> // Add the jump table size >> ActualSize += GetJumpTableSizeInBytes(MJTI); >> - >> + >> // Add the alignment for the function >> ActualSize = RoundUpToAlign(ActualSize, >> std::max(F.getFunction()- >> >getAlignment(), 8U)); >> @@ -1097,7 +1100,7 @@ >> ResultPtr = TheJIT->getPointerToNamedFunction >> (MR.getExternalSymbol(), >> false); >> DEBUG(errs() << "JIT: Map \'" << MR.getExternalSymbol() >> << "\' to [" >> - << ResultPtr << "]\n"); >> + << ResultPtr << "]\n"); >> >> // If the target REALLY wants a stub for this function, >> emit it now. >> if (MR.mayNeedFarStub()) { >> @@ -1255,7 +1258,7 @@ >> >> if (MMI) >> MMI->EndFunction(); >> - >> + >> return false; >> } >> >> @@ -1293,20 +1296,20 @@ >> // If the function did not reference any stubs, return. >> if (CurFnStubUses.find(F) == CurFnStubUses.end()) >> return; >> - >> + >> // For each referenced stub, erase the reference to this >> function, and then >> // erase the list of referenced stubs. >> SmallVectorImpl &StubList = CurFnStubUses[F]; >> for (unsigned i = 0, e = StubList.size(); i != e; ++i) { >> void *Stub = StubList[i]; >> - >> + >> // If we already invalidated this stub for this function, >> continue. >> if (StubFnRefs.count(Stub) == 0) >> continue; >> - >> + >> SmallPtrSet &FnRefs = StubFnRefs[Stub]; >> FnRefs.erase(F); >> - >> + >> // If this function was the last reference to the stub, >> invalidate the stub >> // in the JITResolver. Were there a memory manager >> deallocateStub routine, >> // we could call that at this point too. >> @@ -1389,7 +1392,7 @@ >> >> const std::vector &JT = MJTI->getJumpTables >> (); >> if (JT.empty()) return; >> - >> + >> unsigned NumEntries = 0; >> for (unsigned i = 0, e = JT.size(); i != e; ++i) >> NumEntries += JT[i].MBBs.size(); >> @@ -1409,7 +1412,7 @@ >> >> const std::vector &JT = MJTI->getJumpTables >> (); >> if (JT.empty() || JumpTableBase == 0) return; >> - >> + >> if (TargetMachine::getRelocationModel() == Reloc::PIC_) { >> assert(MJTI->getEntrySize() == 4 && "Cross JIT'ing?"); >> // For each jump table, place the offset from the beginning of >> the table >> @@ -1428,8 +1431,8 @@ >> } >> } else { >> assert(MJTI->getEntrySize() == sizeof(void*) && "Cross >> JIT'ing?"); >> - >> - // For each jump table, map each target in the jump table to >> the address of >> + >> + // For each jump table, map each target in the jump table to >> the address of >> // an emitted MachineBasicBlock. >> intptr_t *SlotPtr = (intptr_t*)JumpTableBase; >> >> @@ -1448,7 +1451,7 @@ >> SavedBufferBegin = BufferBegin; >> SavedBufferEnd = BufferEnd; >> SavedCurBufferPtr = CurBufferPtr; >> - >> + >> BufferBegin = CurBufferPtr = MemMgr->allocateStub(GV, StubSize, >> Alignment); >> BufferEnd = BufferBegin+StubSize+1; >> } >> @@ -1458,7 +1461,7 @@ >> SavedBufferBegin = BufferBegin; >> SavedBufferEnd = BufferEnd; >> SavedCurBufferPtr = CurBufferPtr; >> - >> + >> BufferBegin = CurBufferPtr = (uint8_t *)Buffer; >> BufferEnd = BufferBegin+StubSize+1; >> } >> @@ -1487,15 +1490,15 @@ >> uintptr_t JITEmitter::getJumpTableEntryAddress(unsigned Index) >> const { >> const std::vector &JT = JumpTable- >> >getJumpTables(); >> assert(Index < JT.size() && "Invalid jump table index!"); >> - >> + >> unsigned Offset = 0; >> unsigned EntrySize = JumpTable->getEntrySize(); >> - >> + >> for (unsigned i = 0; i < Index; ++i) >> Offset += JT[i].MBBs.size(); >> - >> + >> Offset *= EntrySize; >> - >> + >> return (uintptr_t)((char *)JumpTableBase + Offset); >> } >> >> @@ -1540,7 +1543,7 @@ >> // If we have already code generated the function, just return >> the address. >> if (void *Addr = getPointerToGlobalIfAvailable(F)) >> return Addr; >> - >> + >> // Get a stub if the target supports it. >> assert(isa(JCE) && "Unexpected MCE?"); >> JITEmitter *JE = cast(getCodeEmitter()); >> >> Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=86941&r1=86940&r2=86941&view=diff >> >> === >> === >> === >> ===================================================================== >> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) >> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Wed Nov 11 >> 21:12:18 2009 >> @@ -61,6 +61,7 @@ >> public: >> RecordingJITMemoryManager() >> : Base(JITMemoryManager::CreateDefaultMemManager()) { >> + stubsAllocated = 0; >> } >> >> virtual void setMemoryWritable() { Base->setMemoryWritable(); } >> @@ -88,8 +89,10 @@ >> StartFunctionBodyCall(Result, F, InitialActualSize, >> ActualSize)); >> return Result; >> } >> + int stubsAllocated; >> virtual uint8_t *allocateStub(const GlobalValue* F, unsigned >> StubSize, >> unsigned Alignment) { >> + stubsAllocated++; >> return Base->allocateStub(F, StubSize, Alignment); >> } >> struct EndFunctionBodyCall { >> @@ -455,6 +458,44 @@ >> NumTablesDeallocated); >> } >> >> +typedef int (*FooPtr) (); >> + >> +TEST_F(JITTest, NoStubs) { >> + LoadAssembly("define void @bar() {" >> + "entry: " >> + "ret void" >> + "}" >> + " " >> + "define i32 @foo() {" >> + "entry:" >> + "call void @bar()" >> + "ret i32 undef" >> + "}" >> + " " >> + "define i32 @main() {" >> + "entry:" >> + "%0 = call i32 @foo()" >> + "call void @bar()" >> + "ret i32 undef" >> + "}"); >> + Function *foo = M->getFunction("foo"); >> + uintptr_t tmp = (uintptr_t)(TheJIT->getPointerToFunction(foo)); >> + FooPtr ptr = (FooPtr)(tmp); >> + >> + (ptr)(); >> + >> + // We should now allocate no more stubs, we have the code to foo >> + // and the existing stub for bar. >> + int stubsBefore = RJMM->stubsAllocated; >> + Function *func = M->getFunction("main"); >> + TheJIT->getPointerToFunction(func); >> + >> + Function *bar = M->getFunction("bar"); >> + TheJIT->getPointerToFunction(bar); >> + >> + ASSERT_EQ(stubsBefore, RJMM->stubsAllocated); >> +} >> + >> // This code is copied from JITEventListenerTest, but it only runs >> once for all >> // the tests in this directory. Everything seems fine, but that's >> strange >> // behavior. >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From grosbach at apple.com Thu Nov 12 11:25:07 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 Nov 2009 17:25:07 -0000 Subject: [llvm-commits] [llvm] r86999 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911121725.nACHP7RP031792@zion.cs.uiuc.edu> Author: grosbach Date: Thu Nov 12 11:25:07 2009 New Revision: 86999 URL: http://llvm.org/viewvc/llvm-project?rev=86999&view=rev Log: Update TB[BH] layout optimization. Add support for moving the target block to directly follow the jump table. Move the layout changes to prior to any constant island handling. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=86999&r1=86998&r2=86999&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Nov 12 11:25:07 2009 @@ -44,6 +44,7 @@ STATISTIC(NumT2BrShrunk, "Number of Thumb2 immediate branches shrunk"); STATISTIC(NumCBZ, "Number of CBZ / CBNZ formed"); STATISTIC(NumJTMoved, "Number of jump table destination blocks moved"); +STATISTIC(NumJTInserted, "Number of jump table intermediate blocks inserted"); static cl::opt @@ -181,6 +182,7 @@ void DoInitialPlacement(MachineFunction &MF, std::vector &CPEMIs); CPEntry *findConstPoolEntry(unsigned CPI, const MachineInstr *CPEMI); + void JumpTableFunctionScan(MachineFunction &MF); void InitialFunctionScan(MachineFunction &MF, const std::vector &CPEMIs); MachineBasicBlock *SplitBlockBeforeInstr(MachineInstr *MI); @@ -208,6 +210,7 @@ bool UndoLRSpillRestore(); bool OptimizeThumb2Instructions(MachineFunction &MF); bool OptimizeThumb2Branches(MachineFunction &MF); + bool ReorderThumb2JumpTables(MachineFunction &MF); bool OptimizeThumb2JumpTables(MachineFunction &MF); MachineBasicBlock *AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB); @@ -271,6 +274,20 @@ // the numbers agree with the position of the block in the function. MF.RenumberBlocks(); + // Try to reorder and otherwise adjust the block layout to make good use + // of the TB[BH] instructions. + bool MadeChange = false; + if (isThumb2 && AdjustJumpTableBlocks) { + JumpTableFunctionScan(MF); + MadeChange |= ReorderThumb2JumpTables(MF); + // Data is out of date, so clear it. It'll be re-computed later. + BBSizes.clear(); + BBOffsets.clear(); + T2JumpTables.clear(); + // Blocks may have shifted around. Keep the numbering up to date. + MF.RenumberBlocks(); + } + // Thumb1 functions containing constant pools get 4-byte alignment. // This is so we can keep exact track of where the alignment padding goes. @@ -301,7 +318,6 @@ // Iteratively place constant pool entries and fix up branches until there // is no change. - bool MadeChange = false; unsigned NoCPIters = 0, NoBRIters = 0; while (true) { bool CPChange = false; @@ -418,6 +434,39 @@ return NULL; } +/// JumpTableFunctionScan - Do a scan of the function, building up +/// information about the sizes of each block and the locations of all +/// the jump tables. +void ARMConstantIslands::JumpTableFunctionScan(MachineFunction &MF) { + unsigned Offset = 0; + for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end(); + MBBI != E; ++MBBI) { + MachineBasicBlock &MBB = *MBBI; + + unsigned MBBSize = 0; + for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); + I != E; ++I) { + // Add instruction size to MBBSize. + MBBSize += TII->GetInstSizeInBytes(I); + + int Opc = I->getOpcode(); + if (I->getDesc().isBranch()) { + switch (Opc) { + default: + continue; // Ignore other JT branches + case ARM::t2BR_JT: + T2JumpTables.push_back(I); + continue; // Does not get an entry in ImmBranches + } + } + } + + BBSizes.push_back(MBBSize); + BBOffsets.push_back(Offset); + Offset += MBBSize; + } +} + /// InitialFunctionScan - Do the initial scan of the function, building up /// information about the sizes of each block, the location of all the water, /// and finding all of the constant pool users. @@ -1561,7 +1610,6 @@ return MadeChange; } - /// OptimizeThumb2JumpTables - Use tbb / tbh instructions to generate smaller /// jumptables when it's possible. bool ARMConstantIslands::OptimizeThumb2JumpTables(MachineFunction &MF) { @@ -1580,33 +1628,10 @@ unsigned JTI = JTOP.getIndex(); assert(JTI < JT.size()); - // We prefer if target blocks for the jump table come after the jump - // instruction so we can use TB[BH]. Loop through the target blocks - // and try to adjust them such that that's true. - unsigned JTOffset = GetOffsetOf(MI) + 4; - const std::vector &JTBBs = JT[JTI].MBBs; - if (AdjustJumpTableBlocks) { - for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { - MachineBasicBlock *MBB = JTBBs[j]; - unsigned DstOffset = BBOffsets[MBB->getNumber()]; - - if (DstOffset < JTOffset) { - // The destination precedes the switch. Try to move the block forward - // so we have a positive offset. - MachineBasicBlock *NewBB = - AdjustJTTargetBlockForward(MBB, MI->getParent()); - if (NewBB) { - MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); - JTOffset = GetOffsetOf(MI) + 4; - DstOffset = BBOffsets[MBB->getNumber()]; - } - } - } - } - bool ByteOk = true; bool HalfWordOk = true; - JTOffset = GetOffsetOf(MI) + 4; + unsigned JTOffset = GetOffsetOf(MI) + 4; + const std::vector &JTBBs = JT[JTI].MBBs; for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { MachineBasicBlock *MBB = JTBBs[j]; unsigned DstOffset = BBOffsets[MBB->getNumber()]; @@ -1693,16 +1718,73 @@ return MadeChange; } +/// ReorderThumb2JumpTables - Use tbb / tbh instructions to generate smaller +/// jumptables when it's possible. +bool ARMConstantIslands::ReorderThumb2JumpTables(MachineFunction &MF) { + bool MadeChange = false; + + MachineJumpTableInfo *MJTI = MF.getJumpTableInfo(); + const std::vector &JT = MJTI->getJumpTables(); + for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) { + MachineInstr *MI = T2JumpTables[i]; + const TargetInstrDesc &TID = MI->getDesc(); + unsigned NumOps = TID.getNumOperands(); + unsigned JTOpIdx = NumOps - (TID.isPredicable() ? 3 : 2); + MachineOperand JTOP = MI->getOperand(JTOpIdx); + unsigned JTI = JTOP.getIndex(); + assert(JTI < JT.size()); + + // We prefer if target blocks for the jump table come after the jump + // instruction so we can use TB[BH]. Loop through the target blocks + // and try to adjust them such that that's true. + unsigned JTOffset = GetOffsetOf(MI) + 4; + const std::vector &JTBBs = JT[JTI].MBBs; + for (unsigned j = 0, ee = JTBBs.size(); j != ee; ++j) { + MachineBasicBlock *MBB = JTBBs[j]; + unsigned DstOffset = BBOffsets[MBB->getNumber()]; + + if (DstOffset < JTOffset) { + // The destination precedes the switch. Try to move the block forward + // so we have a positive offset. + MachineBasicBlock *NewBB = + AdjustJTTargetBlockForward(MBB, MI->getParent()); + if (NewBB) + MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); + MadeChange = true; + } + } + } + + return MadeChange; +} + MachineBasicBlock *ARMConstantIslands:: AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB) { MachineFunction &MF = *BB->getParent(); - // FIXME: For now, instead of moving the block, we'll create a new block - // immediate following the jump that's an unconditional branch to the - // actual target. This is obviously not what we want for a real solution, - // but it's useful for proof of concept, and it may be a useful fallback - // later for cases where we otherwise can't move a block. + // FIXME: If it's a small block terminated by an unconditional branch, + // try to move it; otherwise, create a new block following the jump + // table that branches back to the actual target. This is an overly + // simplistic heuristic here for proof-of-concept. + + int BBI = BB->getNumber(); + int Size = BBSizes[BBI]; + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + // If the block terminator isn't analyzable, don't try to move the block + if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond)) + return NULL; + + // If the block is small and ends in an unconditional branch, move it. + if (Size < 50 && Cond.empty()) { + MachineFunction::iterator OldPrior = prior(BB); + BB->moveAfter(JTBB); + OldPrior->updateTerminator(); + //BB->updateTerminator(); + ++NumJTMoved; + return NULL; + } // Create a new MBB for the code after the jump BB. MachineBasicBlock *NewBB = @@ -1750,6 +1832,6 @@ // All BBOffsets following these blocks must be modified. AdjustBBOffsetsAfter(NewBB, 4); - ++NumJTMoved; + ++NumJTInserted; return NewBB; } From espindola at google.com Thu Nov 12 11:30:07 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 12 Nov 2009 12:30:07 -0500 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <87639f6a8l.fsf@telefonica.net> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> <87639f6a8l.fsf@telefonica.net> Message-ID: <38a0d8450911120930s3421a22t85cc80402c601851@mail.gmail.com> > You shouldn't care about how the inners of cmake work. Specifically, the > user is advised to *not* look at the makefiles. > > So far my experience indicates that performance is similar to the > configure build, and having dependencies right is quite easy, given the > complexity of the LLVM build. Maintenance of the cmake LLVM build system > is easier than maintaining the old single Makefile that my compiler > project used, and that only provided support for 6 compilers on 2 > platforms. I did 1 or 2 builds with cmake and the build time looks similar. cmake itself is much faster than configure. I do care about the generated Makefiles because recursive makes are slow in the case only one file has changed. It should be possible to convert the current build to use non recursive makes, but I have no idea if cmake supports that. > -- > ?scar > Cheers, -- Rafael ?vila de Esp?ndola From chandlerc at google.com Thu Nov 12 11:41:49 2009 From: chandlerc at google.com (Chandler Carruth) Date: Thu, 12 Nov 2009 09:41:49 -0800 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <38a0d8450911120930s3421a22t85cc80402c601851@mail.gmail.com> References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> <87639f6a8l.fsf@telefonica.net> <38a0d8450911120930s3421a22t85cc80402c601851@mail.gmail.com> Message-ID: <74c447500911120941q3c46f5b0iab8a498311e3cd61@mail.gmail.com> On Thu, Nov 12, 2009 at 9:30 AM, Rafael Espindola wrote: >> You shouldn't care about how the inners of cmake work. Specifically, the >> user is advised to *not* look at the makefiles. >> >> So far my experience indicates that performance is similar to the >> configure build, and having dependencies right is quite easy, given the >> complexity of the LLVM build. Maintenance of the cmake LLVM build system >> is easier than maintaining the old single Makefile that my compiler >> project used, and that only provided support for 6 compilers on 2 >> platforms. > > I did 1 or 2 builds with cmake and the build time looks similar. cmake > itself is much faster than configure. > > I do care about the generated Makefiles because recursive makes are > slow in the case only one file has changed. It should be possible to > convert the current build to use non recursive makes, but I have no > idea if cmake supports that. CMake supports non-recursive 'CMakeLists.txt' specifications -- I use several in other projects. If I recall the internal makefile structure correctly, there is some recursion, but it is both explicit and remarkably fast. My very rusty memory of it is that it collapses empty directories so that you end up jumping immediately to each target. -Chandler > >> -- >> ?scar >> > > Cheers, > -- > Rafael ?vila de Esp?ndola > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From benny.kra at googlemail.com Thu Nov 12 11:59:45 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 12 Nov 2009 17:59:45 -0000 Subject: [llvm-commits] [llvm] r87002 - /llvm/trunk/include/llvm/BasicBlock.h Message-ID: <200911121759.nACHxjXI000668@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 12 11:59:45 2009 New Revision: 87002 URL: http://llvm.org/viewvc/llvm-project?rev=87002&view=rev Log: Silence a warning on targets with unsigned chars. Modified: llvm/trunk/include/llvm/BasicBlock.h Modified: llvm/trunk/include/llvm/BasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=87002&r1=87001&r2=87002&view=diff ============================================================================== --- llvm/trunk/include/llvm/BasicBlock.h (original) +++ llvm/trunk/include/llvm/BasicBlock.h Thu Nov 12 11:59:45 2009 @@ -247,7 +247,7 @@ /// almost never 2, and inconceivably 3 or more. void AdjustBlockAddressRefCount(int Amt) { SubclassData += Amt; - assert((int)(char)SubclassData >= 0 && "Refcount wrap-around"); + assert((int)(signed char)SubclassData >= 0 && "Refcount wrap-around"); } }; From ofv at wanadoo.es Thu Nov 12 12:20:35 2009 From: ofv at wanadoo.es (=?windows-1252?Q?=D3scar_Fuentes?=) Date: Thu, 12 Nov 2009 19:20:35 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> <87639f6a8l.fsf@telefonica.net> <38a0d8450911120930s3421a22t85cc80402c601851@mail.gmail.com> Message-ID: <87ws1v4nbg.fsf@telefonica.net> Rafael Espindola writes: > I did 1 or 2 builds with cmake and the build time looks similar. cmake > itself is much faster than configure. > > I do care about the generated Makefiles because recursive makes are > slow in the case only one file has changed. It should be possible to > convert the current build to use non recursive makes, but I have no > idea if cmake supports that. Hmmm... touch ../head/tools/opt.cpp time make -j4 (on the toplevel build directory) For cmake: 3.9 seconds For configure: 4.8 seconds -- ?scar From dpatel at apple.com Thu Nov 12 12:31:58 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 Nov 2009 18:31:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r87008 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200911121831.nACIVw79002075@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 12 12:31:57 2009 New Revision: 87008 URL: http://llvm.org/viewvc/llvm-project?rev=87008&view=rev Log: "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for locations and types. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=87008&r1=87007&r2=87008&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Nov 12 12:31:57 2009 @@ -250,9 +250,6 @@ Fn->hasInternalLinkage(), true /*definition*/); -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - DebugFactory.InsertSubprogramStart(SP, CurBB); -#endif // Push function on region stack. RegionStack.push_back(SP); RegionMap[FnDecl] = SP; @@ -293,9 +290,6 @@ /// region - "llvm.dbg.region.end." void DebugInfo::EmitFunctionEnd(BasicBlock *CurBB, bool EndFunction) { assert(!RegionStack.empty() && "Region stack mismatch, stack empty!"); -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - DebugFactory.InsertRegionEnd(RegionStack.back(), CurBB); -#endif RegionStack.pop_back(); // Blocks get erased; clearing these is needed for determinism, and also // a good idea if the next function gets inlined. @@ -334,14 +328,12 @@ Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - llvm::DIDescriptor DR = RegionStack.back(); - llvm::DIScope DS = llvm::DIScope(DR.getNode()); - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); - Builder.SetDebugLocation(Call, DL.getNode()); -#endif + llvm::DIDescriptor DR = RegionStack.back(); + llvm::DIScope DS = llvm::DIScope(DR.getNode()); + llvm::DILocation DO(NULL); + llvm::DILocation DL = + DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); + Builder.SetDebugLocation(Call, DL.getNode()); } @@ -388,7 +380,7 @@ // or in Apple Block helper functions. if (!isPartOfAppleBlockPrologue(CurLineNo) && !isCopyOrDestroyHelper(cfun->decl)) { -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN + if (RegionStack.empty()) return; llvm::DIDescriptor DR = RegionStack.back(); @@ -397,11 +389,6 @@ llvm::DILocation DL = DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); Builder.SetCurrentDebugLocation(DL.getNode()); -#else - DebugFactory.InsertStopPoint(getOrCreateCompileUnit(CurFullPath), - CurLineNo, 0 /*column no. */, - CurBB); -#endif } } From ofv at wanadoo.es Thu Nov 12 12:33:56 2009 From: ofv at wanadoo.es (=?windows-1252?Q?=D3scar_Fuentes?=) Date: Thu, 12 Nov 2009 19:33:56 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in References: <200911120546.nAC5kAb3024435@zion.cs.uiuc.edu> <87k4xw5lkt.fsf@telefonica.net> <38a0d8450911112218p8a81f22t4ee17416c684648d@mail.gmail.com> <38a0d8450911120609je10f343i59f6d4768f60861@mail.gmail.com> <87639f6a8l.fsf@telefonica.net> <38a0d8450911120930s3421a22t85cc80402c601851@mail.gmail.com> <87ws1v4nbg.fsf@telefonica.net> Message-ID: <87skcj4mp7.fsf@telefonica.net> ?scar Fuentes writes: > Rafael Espindola > writes: > >> I did 1 or 2 builds with cmake and the build time looks similar. cmake >> itself is much faster than configure. >> >> I do care about the generated Makefiles because recursive makes are >> slow in the case only one file has changed. It should be possible to >> convert the current build to use non recursive makes, but I have no >> idea if cmake supports that. > > Hmmm... > > touch ../head/tools/opt.cpp > > time make -j4 (on the toplevel build directory) > > For cmake: 3.9 seconds > For configure: 4.8 seconds Of course the hand-made makefiles LLVM uses are recursive too, but I think that 4 seconds for checking the dependencies of all those targets *and* building opt is pretty fast :-) When make is invoked with all targets updated (i.e. nothing needs a rebuild) the cmake makefiles are consintly faster than the LLVM ones (2.2 seconds vs 1.4 seconds, make -j4) This may be the cause of the specific way the LLVM makefiles are written, and possibly non-recursive makefiles could be even faster, but we are pretty fast now. And who would write and maintain those non-recursive makefiles? :-) So recursive makefiles is no argument against cmake right now, IMO. -- ?scar From gohman at apple.com Thu Nov 12 12:36:19 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 18:36:19 -0000 Subject: [llvm-commits] [llvm] r87009 - /llvm/trunk/include/llvm/Target/Target.td Message-ID: <200911121836.nACIaJKb002299@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 12 12:36:19 2009 New Revision: 87009 URL: http://llvm.org/viewvc/llvm-project?rev=87009&view=rev Log: Mark DBG_LABEL, EH_LABEL, and GC_LABEL as not-duplicable, since they really are not duplicable. Modified: llvm/trunk/include/llvm/Target/Target.td Modified: llvm/trunk/include/llvm/Target/Target.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=87009&r1=87008&r2=87009&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Target.td (original) +++ llvm/trunk/include/llvm/Target/Target.td Thu Nov 12 12:36:19 2009 @@ -413,6 +413,7 @@ let AsmString = ""; let Namespace = "TargetInstrInfo"; let hasCtrlDep = 1; + let isNotDuplicable = 1; } def EH_LABEL : Instruction { let OutOperandList = (ops); @@ -420,6 +421,7 @@ let AsmString = ""; let Namespace = "TargetInstrInfo"; let hasCtrlDep = 1; + let isNotDuplicable = 1; } def GC_LABEL : Instruction { let OutOperandList = (ops); @@ -427,6 +429,7 @@ let AsmString = ""; let Namespace = "TargetInstrInfo"; let hasCtrlDep = 1; + let isNotDuplicable = 1; } def KILL : Instruction { let OutOperandList = (ops); From gohman at apple.com Thu Nov 12 12:39:00 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 10:39:00 -0800 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll In-Reply-To: <4AFBBC6B.8010304@free.fr> References: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> <4AFBBC6B.8010304@free.fr> Message-ID: <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> On Nov 11, 2009, at 11:42 PM, Duncan Sands wrote: > Hi Dan, > >> Add support for tail duplication to BranchFolding, and extend >> tail merging support to handle more cases. >> - Recognize several cases where tail merging is beneficial even when >> the tail size is smaller than the generic threshold. >> - Make use of MachineInstrDesc::isBarrier to help detect >> non-fallthrough blocks. >> - Check for and avoid disrupting fall-through edges in more cases. > > can this result in a label being sucked off the end of a block, and > moved into another? Exception handling labels come in pairs, and it > would be wrong to move one of them without the other (even all the > instructions in between). My understanding is that each EH_LABEL has a unique ID, and this automatically prevents two of them from being merged. I just made a change to mark all label instructions as non-duplicable, to prevent tail-duplication and other code-duplicating optimizations from getting into trouble. Dan From gohman at apple.com Thu Nov 12 12:43:33 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 10:43:33 -0800 Subject: [llvm-commits] [llvm] r86404 - in /llvm/trunk/lib/Target/ARM: ARMAddressingModes.h ARMISelDAGToDAG.cpp ARMInstrInfo.td AsmPrinter/ARMAsmPrinter.cpp NEONPreAllocPass.cpp In-Reply-To: <7906991F-4249-4BC1-A2DE-D2CD39932E0F@apple.com> References: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> <90BAE2B3-491D-4D6F-BA26-4A9CD2E54B84@apple.com> <07E25920-8744-4E1E-B020-292B6B32984A@apple.com> <7906991F-4249-4BC1-A2DE-D2CD39932E0F@apple.com> Message-ID: <2979A16D-E5D7-4DE9-AA4B-B8985CF00CFE@apple.com> On Nov 11, 2009, at 6:50 PM, Evan Cheng wrote: > > On Nov 11, 2009, at 8:40 AM, Jim Grosbach wrote: > >> >> On Nov 10, 2009, at 1:27 AM, Evan Cheng wrote: >> >>> >>> On Nov 7, 2009, at 1:25 PM, Jim Grosbach wrote: >>> >>>> >>>> >>>> bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N, >>>> SDValue &Addr, SDValue &Update, >>>> - SDValue &Opc) { >>>> + SDValue &Opc, SDValue &Align) { >>>> Addr = N; >>>> // Default to no writeback. >>>> Update = CurDAG->getRegister(0, MVT::i32); >>>> Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), MVT::i32); >>>> + // Default to no alignment. >>>> + Align = CurDAG->getTargetConstant(0, MVT::i32); >>>> return true; >>>> } >>> >>> Shouldn't we be able to transfer the alignment on the LoadSDNode / StoreSDNode to Align (capped at 64 / 128 for 64-bit / 128-bit memory operations)? >> >> Potentially. I'm concerned about stack objects in frames we don't dynamically align, however. That could result in aligned load/stores of objects w/o guaranteed alignment, and I wanted to avoid that. > > That shouldn't happen. The alignment field on LoadSDNode and StoreSDNode should not be considered optional. They are required. Dan, is that right? Yes. The current (somewhat naive) rule is that a non-zero alignment value on a load or store says that if the dynamic address doesn't have at least that alignment, the behavior is undefined. Dan From espindola at google.com Thu Nov 12 12:59:08 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 12 Nov 2009 13:59:08 -0500 Subject: [llvm-commits] [PATCH] LTO code generator options In-Reply-To: References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> <38a0d8450911101625s5e3b7cb0m31ec0ce4d4144dc@mail.gmail.com> Message-ID: <38a0d8450911121059n6a0d3eb0ka34711d931c7675e@mail.gmail.com> > The updated patch is attached. > > * StringRef is passed by value; > * Removed getArchNameForLLVMArchType; > * Fixed strange alignment. > * Removed all cosmetic changes from this patch. > > Is it Ok to submit? Sorry about the delay. I am not very familiar with this code. About Triple::getArchNameForDarwinArchTriplePart. Its output is passed to the assembler, so the comment "gcc?" should probably be replaced with "architecture name used by the assembler" or something like that. Can you make it non static? So instead of Triple::getArchNameForDarwinArchTriplePart(_targetTriple.getArchName() we would have _targetTriple.getArchNameForDarwinArchTriplePart() If you move the check for "is darwin" into that method you could also rename it into something like getAssemblerArchName. The code that uses it would look like const char *arch = _targetTriple.getAssemblerArchName(); if (arch != NULL) { ... } Just have the method return NULL if it is not darwin. Finally, this part is an (very nice) independent cleanup, no? Would you mind putting it in an independent patch? > Cheers, >Viktor Thanks, -- Rafael ?vila de Esp?ndola From dpatel at apple.com Thu Nov 12 13:02:57 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 Nov 2009 19:02:57 -0000 Subject: [llvm-commits] [llvm] r87014 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/CodeGen/DwarfWriter.h include/llvm/CodeGen/MachineModuleInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/AsmPrinter/DwarfWriter.cpp lib/CodeGen/MachineModuleInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200911121902.nACJ2vo2003474@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 12 13:02:56 2009 New Revision: 87014 URL: http://llvm.org/viewvc/llvm-project?rev=87014&view=rev Log: "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for line number and scopes. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/CodeGen/DwarfWriter.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Nov 12 13:02:56 2009 @@ -26,8 +26,6 @@ #include "llvm/Support/Dwarf.h" #include "llvm/Support/ValueHandle.h" -#define ATTACH_DEBUG_INFO_TO_AN_INSN 1 - namespace llvm { class BasicBlock; class Constant; @@ -710,18 +708,6 @@ /// processSubprogram - Process DISubprogram. void processSubprogram(DISubprogram SP); - /// processStopPoint - Process DbgStopPointInst. - void processStopPoint(DbgStopPointInst *SPI); - - /// processFuncStart - Process DbgFuncStartInst. - void processFuncStart(DbgFuncStartInst *FSI); - - /// processRegionStart - Process DbgRegionStart. - void processRegionStart(DbgRegionStartInst *DRS); - - /// processRegionEnd - Process DbgRegionEnd. - void processRegionEnd(DbgRegionEndInst *DRE); - /// processDeclare - Process DbgDeclareInst. void processDeclare(DbgDeclareInst *DDI); Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original) +++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Thu Nov 12 13:02:56 2009 @@ -87,19 +87,9 @@ /// the source line list. unsigned RecordSourceLine(unsigned Line, unsigned Col, MDNode *Scope); - /// RecordRegionStart - Indicate the start of a region. - unsigned RecordRegionStart(MDNode *N); - - /// RecordRegionEnd - Indicate the end of a region. - unsigned RecordRegionEnd(MDNode *N); - /// getRecordSourceLineCount - Count source lines. unsigned getRecordSourceLineCount(); - /// RecordVariable - Indicate the declaration of a local variable. - /// - void RecordVariable(MDNode *N, unsigned FrameIndex); - /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should /// be emitted. bool ShouldEmitDwarfDebug() const; Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Thu Nov 12 13:02:56 2009 @@ -44,8 +44,6 @@ #include "llvm/Pass.h" #include "llvm/Metadata.h" -#define ATTACH_DEBUG_INFO_TO_AN_INSN 1 - namespace llvm { //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu Nov 12 13:02:56 2009 @@ -1069,29 +1069,18 @@ /// processModule - Process entire module and collect debug info. void DebugInfoFinder::processModule(Module &M) { -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN MetadataContext &TheMetadata = M.getContext().getMetadata(); unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); -#endif + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI) for (BasicBlock::iterator BI = (*FI).begin(), BE = (*FI).end(); BI != BE; ++BI) { - if (DbgStopPointInst *SPI = dyn_cast(BI)) - processStopPoint(SPI); - else if (DbgFuncStartInst *FSI = dyn_cast(BI)) - processFuncStart(FSI); - else if (DbgRegionStartInst *DRS = dyn_cast(BI)) - processRegionStart(DRS); - else if (DbgRegionEndInst *DRE = dyn_cast(BI)) - processRegionEnd(DRE); - else if (DbgDeclareInst *DDI = dyn_cast(BI)) + if (DbgDeclareInst *DDI = dyn_cast(BI)) processDeclare(DDI); -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN else if (MDDbgKind) if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) processLocation(DILocation(L)); -#endif } NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv"); @@ -1168,30 +1157,6 @@ processType(SP.getType()); } -/// processStopPoint - Process DbgStopPointInst. -void DebugInfoFinder::processStopPoint(DbgStopPointInst *SPI) { - MDNode *Context = dyn_cast(SPI->getContext()); - addCompileUnit(DICompileUnit(Context)); -} - -/// processFuncStart - Process DbgFuncStartInst. -void DebugInfoFinder::processFuncStart(DbgFuncStartInst *FSI) { - MDNode *SP = dyn_cast(FSI->getSubprogram()); - processSubprogram(DISubprogram(SP)); -} - -/// processRegionStart - Process DbgRegionStart. -void DebugInfoFinder::processRegionStart(DbgRegionStartInst *DRS) { - MDNode *SP = dyn_cast(DRS->getContext()); - processSubprogram(DISubprogram(SP)); -} - -/// processRegionEnd - Process DbgRegionEnd. -void DebugInfoFinder::processRegionEnd(DbgRegionEndInst *DRE) { - MDNode *SP = dyn_cast(DRE->getContext()); - processSubprogram(DISubprogram(SP)); -} - /// processDeclare - Process DbgDeclareInst. void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) { DIVariable DV(cast(DDI->getVariable())); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Nov 12 13:02:56 2009 @@ -1388,32 +1388,6 @@ return AScope; } -/// getOrCreateScope - Returns the scope associated with the given descriptor. -/// FIXME - Remove this method. -DbgScope *DwarfDebug::getOrCreateScope(MDNode *N) { - DbgScope *&Slot = DbgScopeMap[N]; - if (Slot) return Slot; - - DbgScope *Parent = NULL; - DILexicalBlock Block(N); - - if (!Block.isNull()) { - DIDescriptor ParentDesc = Block.getContext(); - Parent = - ParentDesc.isNull() ? NULL : getOrCreateScope(ParentDesc.getNode()); - } - - Slot = new DbgScope(Parent, DIDescriptor(N)); - - if (Parent) - Parent->AddScope(Slot); - else - // First function is top level function. - CurrentFnDbgScope = Slot; - - return Slot; -} - static DISubprogram getDISubprogram(MDNode *N) { DIDescriptor D(N); @@ -1644,129 +1618,6 @@ return ScopeDIE; } -/// ConstructDbgScope - Construct the components of a scope. -/// FIXME: Remove -void DwarfDebug::ConstructDbgScope(DbgScope *ParentScope, - unsigned ParentStartID, - unsigned ParentEndID, - DIE *ParentDie, CompileUnit *Unit) { - // Add variables to scope. - SmallVector &Variables = ParentScope->getVariables(); - for (unsigned i = 0, N = Variables.size(); i < N; ++i) { - DIE *VariableDie = CreateDbgScopeVariable(Variables[i], Unit); - if (VariableDie) ParentDie->AddChild(VariableDie); - } - - // Add nested scopes. - SmallVector &Scopes = ParentScope->getScopes(); - for (unsigned j = 0, M = Scopes.size(); j < M; ++j) { - // Define the Scope debug information entry. - DbgScope *Scope = Scopes[j]; - - unsigned StartID = MMI->MappedLabel(Scope->getStartLabelID()); - unsigned EndID = MMI->MappedLabel(Scope->getEndLabelID()); - - // Ignore empty scopes. - if (StartID == EndID && StartID != 0) continue; - - // Do not ignore inlined scopes even if they don't have any variables or - // scopes. - if (Scope->getScopes().empty() && Scope->getVariables().empty()) - continue; - - if (StartID == ParentStartID && EndID == ParentEndID) { - // Just add stuff to the parent scope. - ConstructDbgScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit); - } else { - DIE *ScopeDie = new DIE(dwarf::DW_TAG_lexical_block); - - // Add the scope bounds. - if (StartID) - AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("label", StartID)); - else - AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("func_begin", SubprogramCount)); - - if (EndID) - AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("label", EndID)); - else - AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("func_end", SubprogramCount)); - - // Add the scope's contents. - ConstructDbgScope(Scope, StartID, EndID, ScopeDie, Unit); - ParentDie->AddChild(ScopeDie); - } - } -} - -/// ConstructCurrentFnDbgScope - Construct the scope for the subprogram. -/// FIXME: Remove -void DwarfDebug::ConstructCurrentFnDbgScope(DbgScope *RootScope, - bool AbstractScope) { - // Exit if there is no root scope. - if (!RootScope) return; - DIDescriptor Desc = RootScope->getDesc(); - if (Desc.isNull()) - return; - - // Get the subprogram debug information entry. - DISubprogram SPD(Desc.getNode()); - - // Get the subprogram die. - DIE *SPDie = ModuleCU->getDieMapSlotFor(SPD.getNode()); - if (!SPDie) { - ConstructSubprogram(SPD.getNode()); - SPDie = ModuleCU->getDieMapSlotFor(SPD.getNode()); - } - assert(SPDie && "Missing subprogram descriptor"); - - if (!AbstractScope) { - // Add the function bounds. - AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("func_begin", SubprogramCount)); - AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("func_end", SubprogramCount)); - MachineLocation Location(RI->getFrameRegister(*MF)); - AddAddress(SPDie, dwarf::DW_AT_frame_base, Location); - } - - ConstructDbgScope(RootScope, 0, 0, SPDie, ModuleCU); - // If there are global variables at this scope then add their dies. - for (SmallVector::iterator SGI = ScopedGVs.begin(), - SGE = ScopedGVs.end(); SGI != SGE; ++SGI) { - MDNode *N = dyn_cast_or_null(*SGI); - if (!N) continue; - DIGlobalVariable GV(N); - if (GV.getContext().getNode() == RootScope->getDesc().getNode()) { - DIE *ScopedGVDie = CreateGlobalVariableDIE(ModuleCU, GV); - if (ScopedGVDie) - SPDie->AddChild(ScopedGVDie); - } - } -} - -/// ConstructDefaultDbgScope - Construct a default scope for the subprogram. -/// FIXME: Remove -void DwarfDebug::ConstructDefaultDbgScope(MachineFunction *MF) { - StringMap &Globals = ModuleCU->getGlobals(); - StringMap::iterator GI = Globals.find(MF->getFunction()->getName()); - if (GI != Globals.end()) { - DIE *SPDie = GI->second; - - // Add the function bounds. - AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("func_begin", SubprogramCount)); - AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("func_end", SubprogramCount)); - - MachineLocation Location(RI->getFrameRegister(*MF)); - AddAddress(SPDie, dwarf::DW_AT_frame_base, Location); - } -} - /// GetOrCreateSourceID - Look up the source id with the given directory and /// source file names. If none currently exists, create a new id and insert it /// in the SourceIds map. This can update DirectoryNames and SourceFileNames @@ -2241,11 +2092,9 @@ if (TimePassesIsEnabled) DebugTimer->startTimer(); -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN if (!ExtractScopeInformation(MF)) return; CollectVariableInfo(); -#endif // Begin accumulating function debug information. MMI->BeginFunction(MF); @@ -2255,7 +2104,6 @@ // Emit label for the implicitly defined dbg.stoppoint at the start of the // function. -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN DebugLoc FDL = MF->getDefaultDebugLoc(); if (!FDL.isUnknown()) { DebugLocTuple DLT = MF->getDebugLocTuple(FDL); @@ -2268,15 +2116,6 @@ Asm->printLabel(LabelID); O << '\n'; } -#else - DebugLoc FDL = MF->getDefaultDebugLoc(); - if (!FDL.isUnknown()) { - DebugLocTuple DLT = MF->getDebugLocTuple(FDL); - unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.Scope); - Asm->printLabel(LabelID); - O << '\n'; - } -#endif if (TimePassesIsEnabled) DebugTimer->stopTimer(); } @@ -2289,10 +2128,9 @@ if (TimePassesIsEnabled) DebugTimer->startTimer(); -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN if (DbgScopeMap.empty()) return; -#endif + // Define end label for subprogram. EmitLabel("func_end", SubprogramCount); @@ -2307,28 +2145,13 @@ Lines.begin(), Lines.end()); } -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - // Construct scopes for subprogram. - if (CurrentFnDbgScope) - ConstructCurrentFnDbgScope(CurrentFnDbgScope); - else - // FIXME: This is wrong. We are essentially getting past a problem with - // debug information not being able to handle unreachable blocks that have - // debug information in them. In particular, those unreachable blocks that - // have "region end" info in them. That situation results in the "root - // scope" not being created. If that's the case, then emit a "default" - // scope, i.e., one that encompasses the whole function. This isn't - // desirable. And a better way of handling this (and all of the debugging - // information) needs to be explored. - ConstructDefaultDbgScope(MF); -#else // Construct abstract scopes. for (SmallVector::iterator AI = AbstractScopesList.begin(), AE = AbstractScopesList.end(); AI != AE; ++AI) ConstructScopeDIE(*AI); ConstructScopeDIE(CurrentFnDbgScope); -#endif + DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount, MMI->getFrameMoves())); @@ -2406,59 +2229,6 @@ return SrcId; } -/// RecordRegionStart - Indicate the start of a region. -unsigned DwarfDebug::RecordRegionStart(MDNode *N) { - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - DbgScope *Scope = getOrCreateScope(N); - unsigned ID = MMI->NextLabelID(); - if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return ID; -} - -/// RecordRegionEnd - Indicate the end of a region. -unsigned DwarfDebug::RecordRegionEnd(MDNode *N) { - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - DbgScope *Scope = getOrCreateScope(N); - unsigned ID = MMI->NextLabelID(); - Scope->setEndLabelID(ID); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return ID; -} - -/// RecordVariable - Indicate the declaration of a local variable. -void DwarfDebug::RecordVariable(MDNode *N, unsigned FrameIndex) { - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - DIDescriptor Desc(N); - DbgScope *Scope = NULL; - - if (Desc.getTag() == dwarf::DW_TAG_variable) - Scope = getOrCreateScope(DIGlobalVariable(N).getContext().getNode()); - else { - MDNode *Context = DIVariable(N).getContext().getNode(); - Scope = getOrCreateScope(Context); - } - - assert(Scope && "Unable to find the variable's scope"); - DbgVariable *DV = new DbgVariable(DIVariable(N), FrameIndex); - Scope->AddVariable(DV); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); -} - //===----------------------------------------------------------------------===// // Emit Methods //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Nov 12 13:02:56 2009 @@ -367,7 +367,7 @@ /// createDbgScope - Create DbgScope for the scope. void createDbgScope(MDNode *Scope, MDNode *InlinedAt); - DbgScope *getOrCreateScope(MDNode *N); + DbgScope *getOrCreateAbstractScope(MDNode *N); /// findAbstractVariable - Find abstract variable associated with Var. @@ -386,15 +386,6 @@ unsigned ParentStartID, unsigned ParentEndID, DIE *ParentDie, CompileUnit *Unit); - /// ConstructCurrentFnDbgScope - Construct the scope for the subprogram. - /// - void ConstructCurrentFnDbgScope(DbgScope *RootScope, - bool AbstractScope = false); - - /// ConstructDefaultDbgScope - Construct a default scope for the subprogram. - /// - void ConstructDefaultDbgScope(MachineFunction *MF); - /// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc /// tools to recognize the object file contains Dwarf information. void EmitInitial(); @@ -549,15 +540,6 @@ unsigned getOrCreateSourceID(const std::string &DirName, const std::string &FileName); - /// RecordRegionStart - Indicate the start of a region. - unsigned RecordRegionStart(MDNode *N); - - /// RecordRegionEnd - Indicate the end of a region. - unsigned RecordRegionEnd(MDNode *N); - - /// RecordVariable - Indicate the declaration of a local variable. - void RecordVariable(MDNode *N, unsigned FrameIndex); - /// ExtractScopeInformation - Scan machine instructions in this function /// and collect DbgScopes. Return true, if atleast one scope was found. bool ExtractScopeInformation(MachineFunction *MF); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Thu Nov 12 13:02:56 2009 @@ -81,27 +81,11 @@ return DD->RecordSourceLine(Line, Col, Scope); } -/// RecordRegionStart - Indicate the start of a region. -unsigned DwarfWriter::RecordRegionStart(MDNode *N) { - return DD->RecordRegionStart(N); -} - -/// RecordRegionEnd - Indicate the end of a region. -unsigned DwarfWriter::RecordRegionEnd(MDNode *N) { - return DD->RecordRegionEnd(N); -} - /// getRecordSourceLineCount - Count source lines. unsigned DwarfWriter::getRecordSourceLineCount() { return DD->getRecordSourceLineCount(); } -/// RecordVariable - Indicate the declaration of a local variable. -/// -void DwarfWriter::RecordVariable(MDNode *N, unsigned FrameIndex) { - DD->RecordVariable(N, FrameIndex); -} - /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should /// be emitted. bool DwarfWriter::ShouldEmitDwarfDebug() const { Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Thu Nov 12 13:02:56 2009 @@ -76,9 +76,7 @@ FilterEnds.clear(); CallsEHReturn = 0; CallsUnwindInit = 0; -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN VariableDbgInfo.clear(); -#endif } /// AnalyzeModule - Scan the module for global debug information. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Thu Nov 12 13:02:56 2009 @@ -325,48 +325,12 @@ unsigned IID = F->getIntrinsicID(); switch (IID) { default: break; - case Intrinsic::dbg_stoppoint: { - DbgStopPointInst *SPI = cast(I); - if (isValidDebugInfoIntrinsic(*SPI, CodeGenOpt::None)) - setCurDebugLoc(ExtractDebugLocation(*SPI, MF.getDebugLocInfo())); + case Intrinsic::dbg_stoppoint: + case Intrinsic::dbg_region_start: + case Intrinsic::dbg_region_end: + case Intrinsic::dbg_func_start: + // FIXME - Remove this instructions once the dust settles. return true; - } - case Intrinsic::dbg_region_start: { - DbgRegionStartInst *RSI = cast(I); - if (isValidDebugInfoIntrinsic(*RSI, CodeGenOpt::None) && DW - && DW->ShouldEmitDwarfDebug()) { - unsigned ID = - DW->RecordRegionStart(RSI->getContext()); - const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); - BuildMI(MBB, DL, II).addImm(ID); - } - return true; - } - case Intrinsic::dbg_region_end: { - DbgRegionEndInst *REI = cast(I); - if (isValidDebugInfoIntrinsic(*REI, CodeGenOpt::None) && DW - && DW->ShouldEmitDwarfDebug()) { - unsigned ID = 0; - DISubprogram Subprogram(REI->getContext()); - const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); - ID = DW->RecordRegionEnd(REI->getContext()); - BuildMI(MBB, DL, II).addImm(ID); - } - return true; - } - case Intrinsic::dbg_func_start: { - DbgFuncStartInst *FSI = cast(I); - if (!isValidDebugInfoIntrinsic(*FSI, CodeGenOpt::None) || !DW - || !DW->ShouldEmitDwarfDebug()) - return true; - - // This is a beginning of a new function. - MF.setDefaultDebugLoc(ExtractDebugLocation(*FSI, MF.getDebugLocInfo())); - - // llvm.dbg.func_start also defines beginning of function scope. - DW->RecordRegionStart(FSI->getSubprogram()); - return true; - } case Intrinsic::dbg_declare: { DbgDeclareInst *DI = cast(I); if (!isValidDebugInfoIntrinsic(*DI, CodeGenOpt::None) || !DW @@ -390,9 +354,6 @@ MDNode *Dbg = TheMetadata.getMD(MDDbgKind, DI); MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); } -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - DW->RecordVariable(DI->getVariable(), FI); -#endif return true; } case Intrinsic::eh_exception: { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=87014&r1=87013&r2=87014&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Thu Nov 12 13:02:56 2009 @@ -335,25 +335,6 @@ DebugLoc DL; for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { - if (CallInst *CI = dyn_cast(I)) { - if (Function *F = CI->getCalledFunction()) { - switch (F->getIntrinsicID()) { - default: break; - case Intrinsic::dbg_stoppoint: { - DbgStopPointInst *SPI = cast(I); - if (isValidDebugInfoIntrinsic(*SPI, CodeGenOpt::Default)) - DL = ExtractDebugLocation(*SPI, MF->getDebugLocInfo()); - break; - } - case Intrinsic::dbg_func_start: { - DbgFuncStartInst *FSI = cast(I); - if (isValidDebugInfoIntrinsic(*FSI, CodeGenOpt::Default)) - DL = ExtractDebugLocation(*FSI, MF->getDebugLocInfo()); - break; - } - } - } - } PN = dyn_cast(I); if (!PN || PN->use_empty()) continue; @@ -3930,64 +3911,12 @@ I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } - case Intrinsic::dbg_stoppoint: { - DbgStopPointInst &SPI = cast(I); - if (isValidDebugInfoIntrinsic(SPI, CodeGenOpt::Default)) { - MachineFunction &MF = DAG.getMachineFunction(); - DebugLoc Loc = ExtractDebugLocation(SPI, MF.getDebugLocInfo()); - setCurDebugLoc(Loc); - - if (OptLevel == CodeGenOpt::None) - DAG.setRoot(DAG.getDbgStopPoint(Loc, getRoot(), - SPI.getLine(), - SPI.getColumn(), - SPI.getContext())); - } - return 0; - } - case Intrinsic::dbg_region_start: { - DwarfWriter *DW = DAG.getDwarfWriter(); - DbgRegionStartInst &RSI = cast(I); - if (isValidDebugInfoIntrinsic(RSI, OptLevel) && DW - && DW->ShouldEmitDwarfDebug()) { - unsigned LabelID = - DW->RecordRegionStart(RSI.getContext()); - DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), - getRoot(), LabelID)); - } - return 0; - } - case Intrinsic::dbg_region_end: { - DwarfWriter *DW = DAG.getDwarfWriter(); - DbgRegionEndInst &REI = cast(I); - - if (!isValidDebugInfoIntrinsic(REI, OptLevel) || !DW - || !DW->ShouldEmitDwarfDebug()) - return 0; - - DISubprogram Subprogram(REI.getContext()); - - unsigned LabelID = - DW->RecordRegionEnd(REI.getContext()); - DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), - getRoot(), LabelID)); - return 0; - } - case Intrinsic::dbg_func_start: { - DwarfWriter *DW = DAG.getDwarfWriter(); - DbgFuncStartInst &FSI = cast(I); - if (!isValidDebugInfoIntrinsic(FSI, CodeGenOpt::None)) - return 0; - - MachineFunction &MF = DAG.getMachineFunction(); - MF.setDefaultDebugLoc(ExtractDebugLocation(FSI, MF.getDebugLocInfo())); - - if (!DW || !DW->ShouldEmitDwarfDebug()) - return 0; - // llvm.dbg.func_start also defines beginning of function scope. - DW->RecordRegionStart(FSI.getSubprogram()); + case Intrinsic::dbg_stoppoint: + case Intrinsic::dbg_region_start: + case Intrinsic::dbg_region_end: + case Intrinsic::dbg_func_start: + // FIXME - Remove this instructions once the dust settles. return 0; - } case Intrinsic::dbg_declare: { if (OptLevel != CodeGenOpt::None) // FIXME: Variable debug info is not supported here. @@ -4012,7 +3941,7 @@ if (SI == FuncInfo.StaticAllocaMap.end()) return 0; // VLAs. int FI = SI->second; -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); if (MMI) { MetadataContext &TheMetadata = @@ -4021,9 +3950,6 @@ MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &DI); MMI->setVariableDbgInfo(Variable, FI, Dbg); } -#else - DW->RecordVariable(Variable, FI); -#endif return 0; } case Intrinsic::eh_exception: { From david_goodwin at apple.com Thu Nov 12 13:08:22 2009 From: david_goodwin at apple.com (David Goodwin) Date: Thu, 12 Nov 2009 19:08:22 -0000 Subject: [llvm-commits] [llvm] r87015 - in /llvm/trunk/lib/CodeGen: AggressiveAntiDepBreaker.cpp LatencyPriorityQueue.cpp PostRASchedulerList.cpp ScheduleDAG.cpp Message-ID: <200911121908.nACJ8MI6003792@zion.cs.uiuc.edu> Author: david_goodwin Date: Thu Nov 12 13:08:21 2009 New Revision: 87015 URL: http://llvm.org/viewvc/llvm-project?rev=87015&view=rev Log: Rename registers to break output dependencies in addition to anti-dependencies. Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/CodeGen/ScheduleDAG.cpp Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=87015&r1=87014&r2=87015&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Thu Nov 12 13:08:21 2009 @@ -285,7 +285,7 @@ for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end(); P != PE; ++P) { - if (P->getKind() == SDep::Anti) { + if ((P->getKind() == SDep::Anti) || (P->getKind() == SDep::Output)) { unsigned Reg = P->getReg(); if (RegSet.count(Reg) != 0) { Edges.push_back(&*P); @@ -716,7 +716,8 @@ SDep *Edge = Edges[i]; SUnit *NextSU = Edge->getSUnit(); - if (Edge->getKind() != SDep::Anti) continue; + if ((Edge->getKind() != SDep::Anti) && + (Edge->getKind() != SDep::Output)) continue; unsigned AntiDepReg = Edge->getReg(); DEBUG(errs() << "\tAntidep reg: " << TRI->getName(AntiDepReg)); Modified: llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp?rev=87015&r1=87014&r2=87015&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp (original) +++ llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp Thu Nov 12 13:08:21 2009 @@ -55,7 +55,10 @@ SUnit *OnlyAvailablePred = 0; for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit &Pred = *I->getSUnit(); if (!Pred.isScheduled) { // We found an available, but not scheduled, predecessor. If it's the @@ -75,7 +78,10 @@ unsigned NumNodesBlocking = 0; for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + if (getSingleUnscheduledPred(I->getSUnit()) == SU) ++NumNodesBlocking; } @@ -92,7 +98,10 @@ void LatencyPriorityQueue::ScheduledNode(SUnit *SU) { for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + AdjustPriorityOfUnscheduledPreds(I->getSUnit()); } } Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=87015&r1=87014&r2=87015&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Thu Nov 12 13:08:21 2009 @@ -603,7 +603,9 @@ void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU, bool IgnoreAntiDep) { for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; ReleaseSucc(SU, &*I, IgnoreAntiDep); } } @@ -658,7 +660,7 @@ available = true; for (SUnit::const_pred_iterator I = SUnits[i].Preds.begin(), E = SUnits[i].Preds.end(); I != E; ++I) { - if (I->getKind() != SDep::Anti) { + if ((I->getKind() != SDep::Anti) && (I->getKind() != SDep::Output)) { available = false; } else { SUnits[i].NumPredsLeft -= 1; @@ -737,7 +739,9 @@ AntiDepBreaker::AntiDepRegVector AntiDepRegs; for (SUnit::const_pred_iterator I = FoundSUnit->Preds.begin(), E = FoundSUnit->Preds.end(); I != E; ++I) { - if ((I->getKind() == SDep::Anti) && !I->getSUnit()->isScheduled) + if (((I->getKind() == SDep::Anti) || + (I->getKind() == SDep::Output)) && + !I->getSUnit()->isScheduled) AntiDepRegs.push_back(I->getReg()); } Modified: llvm/trunk/lib/CodeGen/ScheduleDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAG.cpp?rev=87015&r1=87014&r2=87015&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAG.cpp Thu Nov 12 13:08:21 2009 @@ -214,7 +214,10 @@ unsigned MaxPredDepth = 0; for (SUnit::const_pred_iterator I = Cur->Preds.begin(), E = Cur->Preds.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit *PredSU = I->getSUnit(); if (PredSU->isDepthCurrent) MaxPredDepth = std::max(MaxPredDepth, @@ -248,7 +251,10 @@ unsigned MaxSuccHeight = 0; for (SUnit::const_succ_iterator I = Cur->Succs.begin(), E = Cur->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit *SuccSU = I->getSUnit(); if (SuccSU->isHeightCurrent) MaxSuccHeight = std::max(MaxSuccHeight, From baldrick at free.fr Thu Nov 12 13:13:59 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Nov 2009 20:13:59 +0100 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll In-Reply-To: <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> References: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> <4AFBBC6B.8010304@free.fr> <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> Message-ID: <4AFC5E77.80307@free.fr> > I just made a change to mark all label instructions as non-duplicable, > to prevent tail-duplication and other code-duplicating optimizations > from getting into trouble. Thanks Dan. From jyasskin at gmail.com Thu Nov 12 13:19:16 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Thu, 12 Nov 2009 19:19:16 +0000 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls Message-ID: <001636ed6e725660440478316be4@google.com> Reviewers: gohman_apple.com, Message: Patch at http://codereview.appspot.com/download/issue154066_1033.diff I'm unfamiliar with the code generator, so please go over that part of the change with a fine-toothed comb. This patch doesn't include r86941, assuming that'll be rolled back temporarily. Description: The large code model is documented at http://www.x86-64.org/documentation/abi.pdf and says that calls should assume their target doesn't live within the 32-bit pc-relative offset that fits in the call instruction. The best fix, turning off the global-address->target-global-address conversion in X86TargetLowering::LowerCall(), breaks the lazy JIT because it can separate the movabs(imm->reg) from the actual call instruction. The lazy JIT receives the address of the movabs as a relocation and needs to record the return address from the call; and then when that call happens, it needs to patch the movabs with the newly-compiled target. We could thread the call instruction into the relocation and record the movabs<->call mapping explicitly, but that seems to require at least as much new complication in the code generator as this change. The second attempt defined a new CALL64i pseudo-instruction, which expanded to a 2-instruction sequence in the assembly output and was special-cased in the X86CodeEmitter's emitInstruction() function. That breaks indirect calls, which stop using distinct stubs for each lazily-compiled function. The third attempt goes back to the first approach but makes lazy functions _always_ go through a call stub. This works. You'd think we'd only have to force lazy calls through a stub on difficult platforms, but that turns out to break indirect calls through a function pointer. The right fix for that is to distinguish between calls and address-of operations on uncompiled functions, but that's complex enough to leave for someone else to do. Please review this at http://codereview.appspot.com/154066 Affected files: M lib/ExecutionEngine/JIT/JITEmitter.cpp M lib/Target/X86/X86CodeEmitter.cpp M lib/Target/X86/X86ISelLowering.cpp M lib/Target/X86/X86JITInfo.cpp M test/ExecutionEngine/stubs.ll M test/Makefile M unittests/ExecutionEngine/JIT/JITTest.cpp M utils/lit/TestFormats.py From baldrick at free.fr Thu Nov 12 13:27:40 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Nov 2009 20:27:40 +0100 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> <4AFBD9EA.4040907@free.fr> <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> Message-ID: <4AFC61AC.8080806@free.fr> Hi Bill, >> doesn't this mean that if a pointer to a nounwind function is passed as a >> call parameter (rather than as the callee), then DoesNotThrow is set to true? >> > If such an instruction existed, then I suppose. What's the best way to determine that it's the "callee" and not a parameter? Do you have an example to work with? I actually think the approach is wrong. A call can be "nounwind" without the callee necessarily being nounwind. Your patch only catches the case of the callee being nounwind. The CallSite doesNotThrow method checks for both of these possibilities. I think what should happen is: at the moment of lowering the IR to SDAG nodes, check "doesNotThrow" on calls and set a corresponding flag in the SDAG node. Check this flag when outputting the dwarf table. Ciao, Duncan. From isanbard at gmail.com Thu Nov 12 13:36:24 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 12 Nov 2009 11:36:24 -0800 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <4AFC61AC.8080806@free.fr> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> <4AFBD9EA.4040907@free.fr> <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> <4AFC61AC.8080806@free.fr> Message-ID: <291C756E-2006-4E03-B4B7-150136242E11@gmail.com> On Nov 12, 2009, at 11:27 AM, Duncan Sands wrote: > Hi Bill, > >>> doesn't this mean that if a pointer to a nounwind function is >>> passed as a >>> call parameter (rather than as the callee), then DoesNotThrow is >>> set to true? >>> >> If such an instruction existed, then I suppose. What's the best way >> to determine that it's the "callee" and not a parameter? Do you >> have an example to work with? > > I actually think the approach is wrong. I'm not surprised. :) > A call can be "nounwind" without the > callee necessarily being nounwind. Your patch only catches the case > of the > callee being nounwind. The CallSite doesNotThrow method checks for > both of > these possibilities. I think what should happen is: at the moment > of lowering > the IR to SDAG nodes, check "doesNotThrow" on calls and set a > corresponding > flag in the SDAG node. Check this flag when outputting the dwarf > table. Possible. Though at the point of DWARF generation, we don't have the SDAG nodes anymore. So it would have to be propagated to the CALL instruction. -bw -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/aeaf5a6a/attachment.html From gohman at apple.com Thu Nov 12 13:46:03 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 11:46:03 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: <001636ed6e725660440478316be4@google.com> References: <001636ed6e725660440478316be4@google.com> Message-ID: <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> On Nov 12, 2009, at 11:19 AM, jyasskin at gmail.com wrote: > Reviewers: gohman_apple.com, > > Message: > Patch at http://codereview.appspot.com/download/issue154066_1033.diff > > I'm unfamiliar with the code generator, so please go over that part of > the change with a fine-toothed comb. In the X86ISelLowering.cpp part, disabling the special handling for GlobalAddresses and ExternalSymbols is fine, but the way the proposed patch does that also happens to disable the "else if (isTailCall)" code immediately below that, which handles indirect tail calls. That code is still needed in the large code model -- the callee needs to be in a specific physical register so that it can survive the epilogue. I'm not familiar enough with JIT stubs to comment on the rest of the patch. Dan From anton at korobeynikov.info Thu Nov 12 14:10:35 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 12 Nov 2009 23:10:35 +0300 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> References: <001636ed6e725660440478316be4@google.com> <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> Message-ID: > In the X86ISelLowering.cpp part, disabling the special handling > for GlobalAddresses and ExternalSymbols is fine, but the way the > proposed patch does that also happens to disable the > "else if (isTailCall)" code immediately below that, which handles > indirect tail calls. That code is still needed in the large code > model -- the callee needs to be in a specific physical register > so that it can survive the epilogue. Also, the check for Is64Bit seems to be redundant - the codemodel setting is valid only in 64 bit mode, thus "large code model" and 32-bit code is undefined :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From greened at obbligato.org Thu Nov 12 14:13:43 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 20:13:43 -0000 Subject: [llvm-commits] [llvm] r87016 - /llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200911122013.nACKDiRH007079@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 14:13:34 2009 New Revision: 87016 URL: http://llvm.org/viewvc/llvm-project?rev=87016&view=rev Log: Add comment flags so AsmPrinter can output additional information when emitting comments. These flags carry semantic information not otherwise easily derivable from the IR text. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=87016&r1=87015&r2=87016&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Nov 12 14:13:34 2009 @@ -86,6 +86,14 @@ DwarfWriter *DW; public: + /// Flags to specify different kinds of comments to output in + /// assembly code. These flags carry semantic information not + /// otherwise easily derivable from the IR text. + /// + enum CommentFlag { + ReloadReuse = 0x1 + }; + /// Output stream on which we're printing assembly code. /// formatted_raw_ostream &O; From greened at obbligato.org Thu Nov 12 14:21:09 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 20:21:09 -0000 Subject: [llvm-commits] [llvm] r87018 - /llvm/trunk/include/llvm/CodeGen/MachineInstr.h Message-ID: <200911122021.nACKLAuS007548@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 14:21:09 2009 New Revision: 87018 URL: http://llvm.org/viewvc/llvm-project?rev=87018&view=rev Log: Add AsmPrinter comment flags to machine instructions so that AsmPrinter can emit extra information in comments. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=87018&r1=87017&r2=87018&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Thu Nov 12 14:21:09 2009 @@ -19,6 +19,7 @@ #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineOperand.h" #include "llvm/Target/TargetInstrDesc.h" #include "llvm/Support/DebugLoc.h" @@ -45,6 +46,13 @@ unsigned short NumImplicitOps; // Number of implicit operands (which // are determined at construction time). + unsigned short AsmPrinterFlags; // Various bits of information used by + // the AsmPrinter to emit helpful + // comments. This is *not* semantic + // information. Do not use this for + // anything other than to convey comment + // information to AsmPrinter. + std::vector Operands; // the operands mmo_iterator MemRefs; // information on memory references mmo_iterator MemRefsEnd; @@ -107,6 +115,22 @@ const MachineBasicBlock* getParent() const { return Parent; } MachineBasicBlock* getParent() { return Parent; } + /// getAsmPrinterFlags - Return the asm printer flags bitvector. + /// + unsigned short getAsmPrinterFlags() const { return AsmPrinterFlags; } + + /// getAsmPrinterFlag - Return whether an AsmPrinter flag is set. + /// + bool getAsmPrinterFlag(AsmPrinter::CommentFlag Flag) const { + return AsmPrinterFlags & Flag; + } + + /// setAsmPrinterFlag - Set a flag for the AsmPrinter. + /// + void setAsmPrinterFlag(unsigned short Flag) { + AsmPrinterFlags |= Flag; + } + /// getDebugLoc - Returns the debug location id of this MachineInstr. /// DebugLoc getDebugLoc() const { return debugLoc; } From greened at obbligato.org Thu Nov 12 14:25:07 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 20:25:07 -0000 Subject: [llvm-commits] [llvm] r87019 - in /llvm/trunk: include/llvm/CodeGen/PseudoSourceValue.h lib/CodeGen/PseudoSourceValue.cpp Message-ID: <200911122025.nACKP7We007698@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 14:25:07 2009 New Revision: 87019 URL: http://llvm.org/viewvc/llvm-project?rev=87019&view=rev Log: Make FixedStackPseudoSourceValue a first-class PseudoSourceValue by making it visible to clients and adding LLVM-style cast capability. This will be used by AsmPrinter to determine when to emit spill comments for an instruction. Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=87019&r1=87018&r2=87019&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Thu Nov 12 14:25:07 2009 @@ -15,6 +15,7 @@ #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H #include "llvm/Value.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { class MachineFrameInfo; @@ -32,7 +33,7 @@ virtual void printCustom(raw_ostream &O) const; public: - PseudoSourceValue(); + PseudoSourceValue(enum ValueTy Subclass = PseudoSourceValueVal); /// isConstant - Test whether the memory pointed to by this /// PseudoSourceValue has a constant value. @@ -76,6 +77,38 @@ /// constant, this doesn't need to identify a specific jump table. static const PseudoSourceValue *getJumpTable(); }; + + /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue + /// for holding FixedStack values, which must include a frame + /// index. + class FixedStackPseudoSourceValue : public PseudoSourceValue { + const int FI; + public: + explicit FixedStackPseudoSourceValue(int fi) : + PseudoSourceValue(FixedStackPseudoSourceValueVal), FI(fi) {} + + /// classof - Methods for support type inquiry through isa, cast, and + /// dyn_cast: + /// + static inline bool classof(const FixedStackPseudoSourceValue *) { + return true; + } + static inline bool classof(const Value *V) { + return V->getValueID() == FixedStackPseudoSourceValueVal; + } + + virtual bool isConstant(const MachineFrameInfo *MFI) const; + + virtual bool isAliased(const MachineFrameInfo *MFI) const; + + virtual bool mayAlias(const MachineFrameInfo *) const; + + virtual void printCustom(raw_ostream &OS) const { + OS << "FixedStack" << FI; + } + + int getFrameIndex(void) const { return FI; } + }; } // End llvm namespace #endif Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=87019&r1=87018&r2=87019&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Thu Nov 12 14:25:07 2009 @@ -43,35 +43,14 @@ // Eventually these should be uniqued on LLVMContext rather than in a managed // static. For now, we can safely use the global context for the time being to // squeak by. -PseudoSourceValue::PseudoSourceValue() : +PseudoSourceValue::PseudoSourceValue(enum ValueTy Subclass) : Value(Type::getInt8PtrTy(getGlobalContext()), - PseudoSourceValueVal) {} + Subclass) {} void PseudoSourceValue::printCustom(raw_ostream &O) const { O << PSVNames[this - *PSVs]; } -namespace { - /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue - /// for holding FixedStack values, which must include a frame - /// index. - class FixedStackPseudoSourceValue : public PseudoSourceValue { - const int FI; - public: - explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {} - - virtual bool isConstant(const MachineFrameInfo *MFI) const; - - virtual bool isAliased(const MachineFrameInfo *MFI) const; - - virtual bool mayAlias(const MachineFrameInfo *) const; - - virtual void printCustom(raw_ostream &OS) const { - OS << "FixedStack" << FI; - } - }; -} - static ManagedStatic > FSValues; const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) { From benny.kra at googlemail.com Thu Nov 12 14:37:00 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 12 Nov 2009 20:37:00 -0000 Subject: [llvm-commits] [llvm] r87020 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Support/StringRef.cpp lib/Target/X86/X86ISelLowering.cpp tools/bugpoint/ToolRunner.cpp Message-ID: <200911122037.nACKb0I7008114@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 12 14:36:59 2009 New Revision: 87020 URL: http://llvm.org/viewvc/llvm-project?rev=87020&view=rev Log: Add compare_lower and equals_lower methods to StringRef. Switch all users of StringsEqualNoCase (from StringExtras.h) to it. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Support/StringRef.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/tools/bugpoint/ToolRunner.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=87020&r1=87019&r2=87020&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 14:36:59 2009 @@ -97,6 +97,11 @@ memcmp(Data, RHS.Data, RHS.Length) == 0); } + /// equals_lower - Check for string equality, ignoring case. + bool equals_lower(StringRef RHS) const { + return Length == RHS.Length && compare_lower(RHS) == 0; + } + /// compare - Compare two strings; the result is -1, 0, or 1 if this string /// is lexicographically less than, equal to, or greater than the \arg RHS. int compare(StringRef RHS) const { @@ -110,6 +115,9 @@ return Length < RHS.Length ? -1 : 1; } + /// compare_lower - Compare two strings, ignoring case. + int compare_lower(StringRef RHS) const; + /// str - Get the contents as an std::string. std::string str() const { return std::string(Data, Length); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=87020&r1=87019&r2=87020&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Thu Nov 12 14:36:59 2009 @@ -22,7 +22,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" @@ -2365,7 +2364,7 @@ assert(*(Constraint.end()-1) == '}' && "Not a brace enclosed constraint?"); // Remove the braces from around the name. - std::string RegName(Constraint.begin()+1, Constraint.end()-1); + StringRef RegName(Constraint.data()+1, Constraint.size()-2); // Figure out which register class contains this reg. const TargetRegisterInfo *RI = TM.getRegisterInfo(); @@ -2388,7 +2387,7 @@ for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end(); I != E; ++I) { - if (StringsEqualNoCase(RegName, RI->getName(*I))) + if (RegName.equals_lower(RI->getName(*I))) return std::make_pair(*I, RC); } } Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=87020&r1=87019&r2=87020&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Thu Nov 12 14:36:59 2009 @@ -15,6 +15,26 @@ const size_t StringRef::npos; #endif +static char ascii_tolower(char x) { + if (x >= 'A' && x <= 'Z') + return x - 'A' + 'a'; + return x; +} + +/// compare_lower - Compare strings, ignoring case. +int StringRef::compare_lower(StringRef RHS) const { + for (size_t I = 0, E = std::min(Length, RHS.Length); I != E; ++I) { + char LHC = ascii_tolower(Data[I]); + char RHC = ascii_tolower(RHS.Data[I]); + if (LHC != RHC) + return LHC < RHC ? -1 : 1; + } + + if (Length == RHS.Length) + return 0; + return Length < RHS.Length ? -1 : 1; +} + //===----------------------------------------------------------------------===// // String Searching //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=87020&r1=87019&r2=87020&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Nov 12 14:36:59 2009 @@ -9595,14 +9595,14 @@ } // GCC allows "st(0)" to be called just plain "st". - if (StringsEqualNoCase("{st}", Constraint)) { + if (StringRef("{st}").equals_lower(Constraint)) { Res.first = X86::ST0; Res.second = X86::RFP80RegisterClass; return Res; } // flags -> EFLAGS - if (StringsEqualNoCase("{flags}", Constraint)) { + if (StringRef("{flags}").equals_lower(Constraint)) { Res.first = X86::EFLAGS; Res.second = X86::CCRRegisterClass; return Res; Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=87020&r1=87019&r2=87020&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original) +++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Thu Nov 12 14:36:59 2009 @@ -18,7 +18,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" // for HAVE_LINK_R #include #include @@ -610,9 +609,10 @@ { for (std::vector::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) { - if (!StringsEqualNoCase(*I, "-arch")) { + StringRef S(*I); + if (!S.equals_lower("-arch")) { ++I; - if ((I != E) && !StringsEqualNoCase(I->c_str(), "arm", strlen("arm"))) { + if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm")) { return true; } } From greened at obbligato.org Thu Nov 12 14:49:23 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 20:49:23 -0000 Subject: [llvm-commits] [llvm] r87022 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ Message-ID: <200911122049.nACKnPDw008707@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 14:49:22 2009 New Revision: 87022 URL: http://llvm.org/viewvc/llvm-project?rev=87022&view=rev Log: Add a bool flag to StackObjects telling whether they reference spill slots. The AsmPrinter will use this information to determine whether to print a spill/reload comment. Remove default argument values. It's too easy to pass a wrong argument value when multiple arguments have default values. Make everything explicit to trap bugs early. Update all targets to adhere to the new interfaces.. Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/CodeGen/RegAllocLocal.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Thu Nov 12 14:49:22 2009 @@ -15,9 +15,11 @@ #define LLVM_CODEGEN_MACHINEFRAMEINFO_H #include "llvm/ADT/BitVector.h" -#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/System/DataTypes.h" #include +#include #include namespace llvm { @@ -106,8 +108,8 @@ // cannot alias any other memory objects. bool isSpillSlot; - StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false, - bool isSS = false) + StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, + bool isSS) : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), isSpillSlot(isSS) {} }; @@ -182,6 +184,10 @@ /// CSIValid - Has CSInfo been set yet? bool CSIValid; + /// SpillObjects - A vector indicating which frame indices refer to + /// spill slots. + SmallVector SpillObjects; + /// MMI - This field is set (via setMachineModuleInfo) by a module info /// consumer (ex. DwarfWriter) to indicate that frame layout information /// should be acquired. Typically, it's the responsibility of the target's @@ -192,6 +198,7 @@ /// TargetFrameInfo - Target information about frame layout. /// const TargetFrameInfo &TFI; + public: explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; @@ -341,7 +348,7 @@ /// index with a negative value. /// int CreateFixedObject(uint64_t Size, int64_t SPOffset, - bool Immutable = true); + bool Immutable, bool isSS); /// isFixedObjectIndex - Returns true if the specified index corresponds to a @@ -374,13 +381,31 @@ return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; } - /// CreateStackObject - Create a new statically sized stack object, returning - /// a nonnegative identifier to represent it. + /// CreateStackObject - Create a new statically sized stack object, + /// returning a nonnegative identifier to represent it. /// - int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS = false) { + int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); - return (int)Objects.size()-NumFixedObjects-1; + int Index = (int)Objects.size()-NumFixedObjects-1; + assert(Index >= 0 && "Bad frame index!"); + if (SpillObjects.size() <= static_cast(Index)) + SpillObjects.resize(Index+1); + SpillObjects[Index] = false; + return Index; + } + + /// CreateSpillStackObject - Create a new statically sized stack + /// object that represents a spill slot, returning a nonnegative + /// identifier to represent it. + /// + int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { + CreateStackObject(Size, Alignment, true); + int Index = (int)Objects.size()-NumFixedObjects-1; + if (SpillObjects.size() <= static_cast(Index)) + SpillObjects.resize(Index+1); + SpillObjects[Index] = true; + return Index; } /// RemoveStackObject - Remove or mark dead a statically sized stack object. @@ -397,10 +422,20 @@ /// int CreateVariableSizedObject() { HasVarSizedObjects = true; - Objects.push_back(StackObject(0, 1)); + Objects.push_back(StackObject(0, 1, 0, false, false)); return (int)Objects.size()-NumFixedObjects-1; } - + + /// isSpillObject - Return whether the index refers to a spill slot. + /// + bool isSpillObject(int Index) const { + // Negative indices can't be spill slots. + if (Index < 0) return false; + assert(static_cast(Index) < SpillObjects.size() && + "Invalid frame index!"); + return SpillObjects[Index]; + } + /// getCalleeSavedInfo - Returns a reference to call saved info vector for the /// current function. const std::vector &getCalleeSavedInfo() const { Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Thu Nov 12 14:49:22 2009 @@ -441,9 +441,10 @@ /// index with a negative value. /// int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset, - bool Immutable) { + bool Immutable, bool isSS) { assert(Size != 0 && "Cannot allocate zero size fixed stack objects!"); - Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable)); + Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable, + isSS)); return -++NumFixedObjects; } Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Thu Nov 12 14:49:22 2009 @@ -341,7 +341,7 @@ if (I != IntervalSSMap.end()) { SS = I->second; } else { - SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); + SS = MFI->CreateSpillStackObject(RC->getSize(), RC->getAlignment()); IntervalSSMap[Reg] = SS; } @@ -957,7 +957,7 @@ if (I != IntervalSSMap.end()) { SS = I->second; } else { - SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); + SS = MFI->CreateSpillStackObject(RC->getSize(), RC->getAlignment()); } MachineInstr* FMI = TII->foldMemoryOperand(*MBB->getParent(), Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Thu Nov 12 14:49:22 2009 @@ -264,7 +264,8 @@ if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx; } else { // Spill it to the stack where we must. - FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->Offset); + FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->Offset, + true, false); } I->setFrameIdx(FrameIdx); Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Thu Nov 12 14:49:22 2009 @@ -261,8 +261,8 @@ return SS; // Already has space allocated? // Allocate a new stack object for this spill location... - int FrameIdx = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment(),true); + int FrameIdx = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), + RC->getAlignment()); // Assign the slot... StackSlotForVirtReg[VirtReg] = FrameIdx; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Nov 12 14:49:22 2009 @@ -1379,7 +1379,7 @@ unsigned StackAlign = std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign); - int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign); + int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign, false); return getFrameIndex(FrameIdx, TLI.getPointerTy()); } @@ -1395,7 +1395,7 @@ TD->getPrefTypeAlignment(Ty2)); MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo(); - int FrameIdx = FrameInfo->CreateStackObject(Bytes, Align); + int FrameIdx = FrameInfo->CreateStackObject(Bytes, Align, false); return getFrameIndex(FrameIdx, TLI.getPointerTy()); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Thu Nov 12 14:49:22 2009 @@ -305,7 +305,7 @@ TySize *= CUI->getZExtValue(); // Get total allocated size. if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects. StaticAllocaMap[AI] = - MF->getFrameInfo()->CreateStackObject(TySize, Align); + MF->getFrameInfo()->CreateStackObject(TySize, Align, false); } for (; BB != EB; ++BB) @@ -4439,7 +4439,7 @@ unsigned Align = TLI.getTargetData()->getPrefTypeAlignment( FTy->getReturnType()); MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align); + int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align, false); const Type *StackSlotPtrType = PointerType::getUnqual(FTy->getReturnType()); DemoteStackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); @@ -5276,7 +5276,7 @@ uint64_t TySize = TLI.getTargetData()->getTypeAllocSize(Ty); unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty); MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align); + int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); Chain = DAG.getStore(Chain, getCurDebugLoc(), OpInfo.CallOperand, StackSlot, NULL, 0); Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Thu Nov 12 14:49:22 2009 @@ -117,8 +117,8 @@ assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT && "attempt to assign stack slot to already spilled register"); const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg); - int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment(), /*isSS*/true); + int SS = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), + RC->getAlignment()); if (LowSpillSlot == NO_STACK_SLOT) LowSpillSlot = SS; if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) @@ -161,8 +161,8 @@ EmergencySpillSlots.find(RC); if (I != EmergencySpillSlots.end()) return I->second; - int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment(), /*isSS*/true); + int SS = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), + RC->getAlignment()); if (LowSpillSlot == NO_STACK_SLOT) LowSpillSlot = SS; if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -774,7 +774,8 @@ // Reserve a slot closest to SP or frame pointer. const TargetRegisterClass *RC = ARM::GPRRegisterClass; RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); + RC->getAlignment(), + false)); } } } @@ -791,7 +792,8 @@ return ARM::LR; } -unsigned ARMBaseRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned +ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const { if (STI.isTargetDarwin() || hasFP(MF)) return FramePtr; return ARM::SP; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -1545,7 +1545,8 @@ if (NextVA.isMemLoc()) { unsigned ArgSize = NextVA.getLocVT().getSizeInBits()/8; MachineFrameInfo *MFI = MF.getFrameInfo(); - int FI = MFI->CreateFixedObject(ArgSize, NextVA.getLocMemOffset()); + int FI = MFI->CreateFixedObject(ArgSize, NextVA.getLocMemOffset(), + true, false); // Create load node to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); @@ -1659,7 +1660,8 @@ assert(VA.getValVT() != MVT::i64 && "i64 should already be lowered"); unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; - int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset()); + int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset(), + true, false); // Create load nodes to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); @@ -1687,7 +1689,8 @@ // the result of va_next. AFI->setVarArgsRegSaveSize(VARegSaveSize); VarArgsFrameIndex = MFI->CreateFixedObject(VARegSaveSize, ArgOffset + - VARegSaveSize - VARegSize); + VARegSaveSize - VARegSize, + true, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, getPointerTy()); SmallVector MemOps; @@ -1711,7 +1714,7 @@ &MemOps[0], MemOps.size()); } else // This will point to the next argument passed via stack. - VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset); + VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset, true, false); } return Chain; Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -426,7 +426,7 @@ } } else { //more args // Create the frame index object for this incoming parameter... - int FI = MFI->CreateFixedObject(8, 8 * (ArgNo - 6)); + int FI = MFI->CreateFixedObject(8, 8 * (ArgNo - 6), true, false); // Create the SelectionDAG nodes corresponding to a load //from this parameter @@ -444,7 +444,7 @@ if (TargetRegisterInfo::isPhysicalRegister(args_int[i])) args_int[i] = AddLiveIn(MF, args_int[i], &Alpha::GPRCRegClass); SDValue argt = DAG.getCopyFromReg(Chain, dl, args_int[i], MVT::i64); - int FI = MFI->CreateFixedObject(8, -8 * (6 - i)); + int FI = MFI->CreateFixedObject(8, -8 * (6 - i), true, false); if (i == 0) VarArgsBase = FI; SDValue SDFI = DAG.getFrameIndex(FI, MVT::i64); LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); @@ -452,7 +452,7 @@ if (TargetRegisterInfo::isPhysicalRegister(args_float[i])) args_float[i] = AddLiveIn(MF, args_float[i], &Alpha::F8RCRegClass); argt = DAG.getCopyFromReg(Chain, dl, args_float[i], MVT::f64); - FI = MFI->CreateFixedObject(8, - 8 * (12 - i)); + FI = MFI->CreateFixedObject(8, - 8 * (12 - i), true, false); SDFI = DAG.getFrameIndex(FI, MVT::i64); LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); } Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -207,7 +207,8 @@ } else { assert(VA.isMemLoc() && "CCValAssign must be RegLoc or MemLoc"); unsigned ObjSize = VA.getLocVT().getStoreSize(); - int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset()); + int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset(), + true, false); SDValue FIN = DAG.getFrameIndex(FI, MVT::i32); InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0)); } Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -368,7 +368,8 @@ if (requiresRegisterScavenging(MF)) { // Reserve a slot close to SP or frame pointer. RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); + RC->getAlignment(), + false)); } } @@ -449,7 +450,8 @@ return BF::RETS; } -unsigned BlackfinRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned +BlackfinRegisterInfo::getFrameRegister(const MachineFunction &MF) const { return hasFP(MF) ? BF::FP : BF::SP; } Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -1090,7 +1090,7 @@ // We need to load the argument to a virtual register if we determined // above that we ran out of physical registers of the appropriate type // or we're forced to do vararg - int FI = MFI->CreateFixedObject(ObjSize, ArgOffset); + int FI = MFI->CreateFixedObject(ObjSize, ArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); ArgOffset += StackSlotSize; @@ -1110,7 +1110,8 @@ // Create the frame slot for (; ArgRegIdx != NumArgRegs; ++ArgRegIdx) { - VarArgsFrameIndex = MFI->CreateFixedObject(StackSlotSize, ArgOffset); + VarArgsFrameIndex = MFI->CreateFixedObject(StackSlotSize, ArgOffset, + true, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); SDValue ArgVal = DAG.getRegister(ArgRegs[ArgRegIdx], MVT::v16i8); SDValue Store = DAG.getStore(Chain, dl, ArgVal, FIN, NULL, 0); Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -318,7 +318,7 @@ << "\n"; } // Create the frame index object for this incoming parameter... - int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset()); + int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset(), true, false); // Create the SelectionDAG nodes corresponding to a load //from this parameter Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -212,7 +212,7 @@ const { // Create a frame entry for the FPW register that must be saved. if (hasFP(MF)) { - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(2, -4); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(2, -4, true, false); assert(FrameIdx == MF.getFrameInfo()->getObjectIndexBegin() && "Slot for FPW register must be last in order to be found!"); FrameIdx = 0; @@ -355,7 +355,7 @@ return MSP430::PCW; } -unsigned MSP430RegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned MSP430RegisterInfo::getFrameRegister(const MachineFunction &MF) const { return hasFP(MF) ? MSP430::FPW : MSP430::SPW; } Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -704,7 +704,7 @@ // the stack (even if less than 4 are used as arguments) if (Subtarget->isABI_O32()) { int VTsize = EVT(MVT::i32).getSizeInBits()/8; - MFI->CreateFixedObject(VTsize, (VTsize*3)); + MFI->CreateFixedObject(VTsize, (VTsize*3), true, false); CCInfo.AnalyzeCallOperands(Outs, CC_MipsO32); } else CCInfo.AnalyzeCallOperands(Outs, CC_Mips); @@ -773,7 +773,7 @@ // if O32 ABI is used. For EABI the first address is zero. LastArgStackLoc = (FirstStackArgLoc + VA.getLocMemOffset()); int FI = MFI->CreateFixedObject(VA.getValVT().getSizeInBits()/8, - LastArgStackLoc); + LastArgStackLoc, true, false); SDValue PtrOff = DAG.getFrameIndex(FI,getPointerTy()); @@ -849,7 +849,7 @@ // Create the frame index only once. SPOffset here can be anything // (this will be fixed on processFunctionBeforeFrameFinalized) if (MipsFI->getGPStackOffset() == -1) { - FI = MFI->CreateFixedObject(4, 0); + FI = MFI->CreateFixedObject(4, 0, true, false); MipsFI->setGPFI(FI); } MipsFI->setGPStackOffset(LastArgStackLoc); @@ -1002,7 +1002,7 @@ // be used on emitPrologue) to avoid mis-calc of the first stack // offset on PEI::calculateFrameObjectOffsets. // Arguments are always 32-bit. - int FI = MFI->CreateFixedObject(4, 0); + int FI = MFI->CreateFixedObject(4, 0, true, false); MipsFI->recordStoreVarArgsFI(FI, -(4+(i*4))); SDValue PtrOff = DAG.getFrameIndex(FI, getPointerTy()); @@ -1025,7 +1025,7 @@ // offset on PEI::calculateFrameObjectOffsets. // Arguments are always 32-bit. unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; - int FI = MFI->CreateFixedObject(ArgSize, 0); + int FI = MFI->CreateFixedObject(ArgSize, 0, true, false); MipsFI->recordLoadArgsFI(FI, -(ArgSize+ (FirstStackArgLoc + VA.getLocMemOffset()))); Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -287,7 +287,7 @@ } if (hasFP(MF)) { - MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize), + MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize, true), StackOffset); MipsFI->setFPStackOffset(StackOffset); TopCPUSavedRegOff = StackOffset; @@ -295,7 +295,7 @@ } if (MFI->hasCalls()) { - MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize), + MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize, true), StackOffset); MipsFI->setRAStackOffset(StackOffset); TopCPUSavedRegOff = StackOffset; @@ -501,7 +501,7 @@ } unsigned MipsRegisterInfo:: -getFrameRegister(MachineFunction &MF) const { +getFrameRegister(const MachineFunction &MF) const { return hasFP(MF) ? Mips::FP : Mips::SP; } Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -1070,7 +1070,7 @@ // Put the value on stack. // Get a stack slot index and convert to es. - int FI = MF.getFrameInfo()->CreateStackObject(1, 1); + int FI = MF.getFrameInfo()->CreateStackObject(1, 1, false); const char *tmpName = createESName(PAN::getTempdataLabel(FuncName)); SDValue ES = DAG.getTargetExternalSymbol(tmpName, MVT::i8); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -1625,7 +1625,7 @@ unsigned ArgSize = VA.getLocVT().getSizeInBits() / 8; int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset(), - isImmutable); + isImmutable, false); // Create load nodes to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, PtrVT); @@ -1690,9 +1690,10 @@ NumFPArgRegs * EVT(MVT::f64).getSizeInBits()/8; VarArgsStackOffset = MFI->CreateFixedObject(PtrVT.getSizeInBits()/8, - CCInfo.getNextStackOffset()); + CCInfo.getNextStackOffset(), + true, false); - VarArgsFrameIndex = MFI->CreateStackObject(Depth, 8); + VarArgsFrameIndex = MFI->CreateStackObject(Depth, 8, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); // The fixed integer arguments of a variadic function are @@ -1895,7 +1896,7 @@ CurArgOffset = CurArgOffset + (4 - ObjSize); } // The value of the object is its address. - int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset); + int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); InVals.push_back(FIN); if (ObjSize==1 || ObjSize==2) { @@ -1918,7 +1919,7 @@ // the object. if (GPR_idx != Num_GPR_Regs) { unsigned VReg = MF.addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass); - int FI = MFI->CreateFixedObject(PtrByteSize, ArgOffset); + int FI = MFI->CreateFixedObject(PtrByteSize, ArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); @@ -2043,7 +2044,7 @@ if (needsLoad) { int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset + (ArgSize - ObjSize), - isImmutable); + isImmutable, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); } @@ -2076,7 +2077,7 @@ int Depth = ArgOffset; VarArgsFrameIndex = MFI->CreateFixedObject(PtrVT.getSizeInBits()/8, - Depth); + Depth, true, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); // If this function is vararg, store any remaining integer argument regs @@ -2289,7 +2290,8 @@ int NewRetAddrLoc = SPDiff + PPCFrameInfo::getReturnSaveOffset(isPPC64, isDarwinABI); int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize, - NewRetAddrLoc); + NewRetAddrLoc, + true, false); EVT VT = isPPC64 ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); Chain = DAG.getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx, @@ -2300,7 +2302,8 @@ if (isDarwinABI) { int NewFPLoc = SPDiff + PPCFrameInfo::getFramePointerSaveOffset(isPPC64, isDarwinABI); - int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc); + int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc, + true, false); SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); Chain = DAG.getStore(Chain, dl, OldFP, NewFramePtrIdx, PseudoSourceValue::getFixedStack(NewFPIdx), 0); @@ -2317,7 +2320,7 @@ SmallVector& TailCallArguments) { int Offset = ArgOffset + SPDiff; uint32_t OpSize = (Arg.getValueType().getSizeInBits()+7)/8; - int FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); + int FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset, true,false); EVT VT = isPPC64 ? MVT::i64 : MVT::i32; SDValue FIN = DAG.getFrameIndex(FI, VT); TailCallArgumentInfo Info; @@ -3224,7 +3227,8 @@ // Find out what the fix offset of the frame pointer save area. int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, isDarwinABI); // Allocate the frame index for frame pointer save area. - RASI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, LROffset); + RASI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, LROffset, + true, false); // Save the result. FI->setReturnAddrSaveIndex(RASI); } @@ -3250,7 +3254,8 @@ isDarwinABI); // Allocate the frame index for frame pointer save area. - FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset); + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset, + true, false); // Save the result. FI->setFramePointerSaveIndex(FPSI); } @@ -3411,7 +3416,7 @@ // then lfd it and fcfid it. MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo *FrameInfo = MF.getFrameInfo(); - int FrameIdx = FrameInfo->CreateStackObject(8, 8); + int FrameIdx = FrameInfo->CreateStackObject(8, 8, false); EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); SDValue FIdx = DAG.getFrameIndex(FrameIdx, PtrVT); @@ -3469,7 +3474,7 @@ SDValue Chain = DAG.getNode(PPCISD::MFFS, dl, NodeTys, &InFlag, 0); // Save FP register to stack slot - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); + int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT); SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Chain, StackSlot, NULL, 0); @@ -4137,7 +4142,7 @@ DebugLoc dl = Op.getDebugLoc(); // Create a stack slot that is 16-byte aligned. MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); - int FrameIdx = FrameInfo->CreateStackObject(16, 16); + int FrameIdx = FrameInfo->CreateStackObject(16, 16, false); EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); SDValue FIdx = DAG.getFrameIndex(FrameIdx, PtrVT); Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -1043,7 +1043,8 @@ int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, isDarwinABI); // Allocate the frame index for frame pointer save area. - FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset); + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset, + true, false); // Save the result. FI->setFramePointerSaveIndex(FPSI); } @@ -1051,7 +1052,8 @@ // Reserve stack space to move the linkage area to in case of a tail call. int TCSPDelta = 0; if (PerformTailCallOpt && (TCSPDelta = FI->getTailCallSPDelta()) < 0) { - MF.getFrameInfo()->CreateFixedObject(-1 * TCSPDelta, TCSPDelta); + MF.getFrameInfo()->CreateFixedObject(-1 * TCSPDelta, TCSPDelta, + true, false); } // Reserve a slot closest to SP or frame pointer if we have a dynalloc or @@ -1067,7 +1069,8 @@ const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *RC = IsPPC64 ? G8RC : GPRC; RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); + RC->getAlignment(), + false)); } } @@ -1711,7 +1714,7 @@ return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8; } -unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned PPCRegisterInfo::getFrameRegister(const MachineFunction &MF) const { if (!Subtarget.isPPC64()) return hasFP(MF) ? PPC::R31 : PPC::R1; else Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -129,7 +129,8 @@ } InVals.push_back(Arg); } else { - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, + true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); SDValue Load; if (ObjectVT == MVT::i32) { @@ -163,7 +164,8 @@ Arg = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::f32, Arg); InVals.push_back(Arg); } else { - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, + true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); SDValue Load = DAG.getLoad(MVT::f32, dl, Chain, FIPtr, NULL, 0); InVals.push_back(Load); @@ -184,7 +186,8 @@ MF.getRegInfo().addLiveIn(*CurArgReg++, VRegHi); HiVal = DAG.getCopyFromReg(Chain, dl, VRegHi, MVT::i32); } else { - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, + true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); HiVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); } @@ -195,7 +198,8 @@ MF.getRegInfo().addLiveIn(*CurArgReg++, VRegLo); LoVal = DAG.getCopyFromReg(Chain, dl, VRegLo, MVT::i32); } else { - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset+4); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset+4, + true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); LoVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); } @@ -227,7 +231,8 @@ MF.getRegInfo().addLiveIn(*CurArgReg, VReg); SDValue Arg = DAG.getCopyFromReg(DAG.getRoot(), dl, VReg, MVT::i32); - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, + true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); OutChains.push_back(DAG.getStore(DAG.getRoot(), dl, Arg, FIPtr, NULL, 0)); Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -329,7 +329,7 @@ // Create the nodes corresponding to a load from this parameter slot. // Create the frame index object for this incoming parameter... int FI = MFI->CreateFixedObject(LocVT.getSizeInBits()/8, - VA.getLocMemOffset()); + VA.getLocMemOffset(), true, false); // Create the SelectionDAG nodes corresponding to a load // from this parameter Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Nov 12 14:49:22 2009 @@ -1493,7 +1493,7 @@ EVT ResVT = RVLocs[0].getValVT(); unsigned Opc = ResVT == MVT::f32 ? X86::ST_Fp80m32 : X86::ST_Fp80m64; unsigned MemSize = ResVT.getSizeInBits()/8; - int FI = MFI.CreateStackObject(MemSize, MemSize); + int FI = MFI.CreateStackObject(MemSize, MemSize, false); addFrameReference(BuildMI(MBB, DL, TII.get(Opc)), FI).addReg(ResultReg); DstRC = ResVT == MVT::f32 ? X86::FR32RegisterClass : X86::FR64RegisterClass; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -1381,7 +1381,7 @@ // In case of tail call optimization mark all arguments mutable. Since they // could be overwritten by lowering of arguments in case of a tail call. int FI = MFI->CreateFixedObject(ValVT.getSizeInBits()/8, - VA.getLocMemOffset(), isImmutable); + VA.getLocMemOffset(), isImmutable, false); SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); if (Flags.isByVal()) return FIN; @@ -1510,7 +1510,7 @@ // the start of the first vararg value... for expansion of llvm.va_start. if (isVarArg) { if (Is64Bit || CallConv != CallingConv::X86_FastCall) { - VarArgsFrameIndex = MFI->CreateFixedObject(1, StackSize); + VarArgsFrameIndex = MFI->CreateFixedObject(1, StackSize, true, false); } if (Is64Bit) { unsigned TotalNumIntRegs = 0, TotalNumXMMRegs = 0; @@ -1561,7 +1561,8 @@ VarArgsGPOffset = NumIntRegs * 8; VarArgsFPOffset = TotalNumIntRegs * 8 + NumXMMRegs * 16; RegSaveFrameIndex = MFI->CreateStackObject(TotalNumIntRegs * 8 + - TotalNumXMMRegs * 16, 16); + TotalNumXMMRegs * 16, 16, + false); // Store the integer parameter registers. SmallVector MemOps; @@ -1682,7 +1683,8 @@ // Calculate the new stack slot for the return address. int SlotSize = Is64Bit ? 8 : 4; int NewReturnAddrFI = - MF.getFrameInfo()->CreateFixedObject(SlotSize, FPDiff-SlotSize); + MF.getFrameInfo()->CreateFixedObject(SlotSize, FPDiff-SlotSize, + true, false); EVT VT = Is64Bit ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx, @@ -1895,7 +1897,7 @@ // Create frame index. int32_t Offset = VA.getLocMemOffset()+FPDiff; uint32_t OpSize = (VA.getLocVT().getSizeInBits()+7)/8; - FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); + FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset, true, false); FIN = DAG.getFrameIndex(FI, getPointerTy()); if (Flags.isByVal()) { @@ -2180,7 +2182,8 @@ if (ReturnAddrIndex == 0) { // Set up a frame object for the return address. uint64_t SlotSize = TD->getPointerSize(); - ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize); + ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize, + true, false); FuncInfo->setRAIndex(ReturnAddrIndex); } @@ -4971,7 +4974,7 @@ DebugLoc dl = Op.getDebugLoc(); unsigned Size = SrcVT.getSizeInBits()/8; MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); + int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand(0), StackSlot, @@ -5005,7 +5008,7 @@ // shouldn't be necessary except that RFP cannot be live across // multiple blocks. When stackifier is fixed, they can be uncoupled. MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); + int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); Tys = DAG.getVTList(MVT::Other); SmallVector Ops; @@ -5215,7 +5218,7 @@ // stack slot. MachineFunction &MF = DAG.getMachineFunction(); unsigned MemSize = DstTy.getSizeInBits()/8; - int SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize); + int SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); unsigned Opc; @@ -5238,7 +5241,7 @@ }; Value = DAG.getNode(X86ISD::FLD, dl, Tys, Ops, 3); Chain = Value.getValue(1); - SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize); + SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize, false); StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); } @@ -6762,7 +6765,7 @@ DebugLoc dl = Op.getDebugLoc(); // Save FP Control Word to stack slot - int SSFI = MF.getFrameInfo()->CreateStackObject(2, StackAlignment); + int SSFI = MF.getFrameInfo()->CreateStackObject(2, StackAlignment, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDValue Chain = DAG.getNode(X86ISD::FNSTCW16m, dl, MVT::Other, @@ -7987,7 +7990,7 @@ // Change the floating point control register to use "round towards zero" // mode when truncating to an integer value. MachineFunction *F = BB->getParent(); - int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2); + int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2, false); addFrameReference(BuildMI(BB, DL, TII->get(X86::FNSTCW16m)), CWFrameIdx); // Load the old value of the high byte of the control word... Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -614,8 +614,8 @@ // Offset is a 32-bit integer. int Offset = getFrameIndexOffset(MF, FrameIndex) + (int)(MI.getOperand(i + 3).getImm()); - - MI.getOperand(i + 3).ChangeToImmediate(Offset); + + MI.getOperand(i + 3).ChangeToImmediate(Offset); } else { // Offset is symbolic. This is extremely rare. uint64_t Offset = getFrameIndexOffset(MF, FrameIndex) + @@ -651,7 +651,8 @@ // } // [EBP] MFI->CreateFixedObject(-TailCallReturnAddrDelta, - (-1U*SlotSize)+TailCallReturnAddrDelta); + (-1U*SlotSize)+TailCallReturnAddrDelta, + true, false); } if (hasFP(MF)) { @@ -663,7 +664,8 @@ int FrameIdx = MFI->CreateFixedObject(SlotSize, -(int)SlotSize + TFI.getOffsetOfLocalArea() + - TailCallReturnAddrDelta); + TailCallReturnAddrDelta, + true, false); assert(FrameIdx == MFI->getObjectIndexBegin() && "Slot for EBP register must be last in order to be found!"); FrameIdx = 0; @@ -1275,7 +1277,7 @@ : X86::EIP; // Should have dwarf #8. } -unsigned X86RegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned X86RegisterInfo::getFrameRegister(const MachineFunction &MF) const { return hasFP(MF) ? FramePtr : StackPtr; } Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Thu Nov 12 14:49:22 2009 @@ -860,7 +860,8 @@ } // Create the frame index object for this incoming parameter... int FI = MFI->CreateFixedObject(ObjSize, - LRSaveSize + VA.getLocMemOffset()); + LRSaveSize + VA.getLocMemOffset(), + true, false); // Create the SelectionDAG nodes corresponding to a load //from this parameter @@ -884,7 +885,7 @@ // address for (unsigned i = array_lengthof(ArgRegs) - 1; i >= FirstVAReg; --i) { // Create a stack slot - int FI = MFI->CreateFixedObject(4, offset); + int FI = MFI->CreateFixedObject(4, offset, true, false); if (i == FirstVAReg) { XFI->setVarArgsFrameIndex(FI); } @@ -905,7 +906,8 @@ } else { // This will point to the next argument passed via stack. XFI->setVarArgsFrameIndex( - MFI->CreateFixedObject(4, LRSaveSize + CCInfo.getNextStackOffset())); + MFI->CreateFixedObject(4, LRSaveSize + CCInfo.getNextStackOffset(), + true, false)); } } Modified: llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Thu Nov 12 14:49:22 2009 @@ -330,9 +330,10 @@ int FrameIdx; if (! isVarArg) { // A fixed offset of 0 allows us to save / restore LR using entsp / retsp. - FrameIdx = MFI->CreateFixedObject(RC->getSize(), 0); + FrameIdx = MFI->CreateFixedObject(RC->getSize(), 0, true, false); } else { - FrameIdx = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); + FrameIdx = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), + false); } XFI->setUsesLR(FrameIdx); XFI->setLRSpillSlot(FrameIdx); @@ -340,13 +341,15 @@ if (requiresRegisterScavenging(MF)) { // Reserve a slot close to SP or frame pointer. RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); + RC->getAlignment(), + false)); } if (hasFP(MF)) { // A callee save register is used to hold the FP. // This needs saving / restoring in the epilogue / prologue. XFI->setFPSpillSlot(MFI->CreateStackObject(RC->getSize(), - RC->getAlignment())); + RC->getAlignment(), + false)); } } @@ -593,7 +596,7 @@ return XCoreGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); } -unsigned XCoreRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned XCoreRegisterInfo::getFrameRegister(const MachineFunction &MF) const { bool FP = hasFP(MF); return FP ? XCore::R10 : XCore::SP; From isanbard at gmail.com Thu Nov 12 14:51:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 12 Nov 2009 20:51:54 -0000 Subject: [llvm-commits] [llvm] r87023 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <200911122051.nACKps7d008820@zion.cs.uiuc.edu> Author: void Date: Thu Nov 12 14:51:53 2009 New Revision: 87023 URL: http://llvm.org/viewvc/llvm-project?rev=87023&view=rev Log: If there's more than one function operand to a call instruction, be conservative and don't assume that the call doesn't throw. It would be nice if there were a way to determine which is the callee and which is a parameter. In practice, the architecture we care about normally only have one operand for a call instruction (x86 and arm). Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=87023&r1=87022&r2=87023&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Thu Nov 12 14:51:53 2009 @@ -494,14 +494,25 @@ // Don't mark a call as potentially throwing if the function it's // calling is marked "nounwind". bool DoesNotThrow = false; + bool SawFunc = false; for (unsigned OI = 0, OE = MI->getNumOperands(); OI != OE; ++OI) { const MachineOperand &MO = MI->getOperand(OI); if (MO.isGlobal()) { if (Function *F = dyn_cast(MO.getGlobal())) { + if (SawFunc) { + // Be conservative. If we have more than one function operand + // for this call, then we can't make the assumption that it's + // the callee and not a parameter to the call. + // + // FIXME: Determine if there's a way to say that `F' is the + // callee or parameter. + DoesNotThrow = false; + break; + } if (F->doesNotThrow()) { + SawFunc = true; DoesNotThrow = true; - break; } } } From daniel at zuster.org Thu Nov 12 14:53:43 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 20:53:43 -0000 Subject: [llvm-commits] [llvm] r87024 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp Message-ID: <200911122053.nACKriBY008897@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 12 14:53:43 2009 New Revision: 87024 URL: http://llvm.org/viewvc/llvm-project?rev=87024&view=rev Log: Fix -Asserts warning. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=87024&r1=87023&r2=87024&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Thu Nov 12 14:53:43 2009 @@ -443,10 +443,9 @@ MachineFunction *MF = A->getParent(); MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(BB); MF->push_back(NMBB); - const unsigned NewNum = NMBB->getNumber(); DEBUG(errs() << "PHIElimination splitting critical edge:" " BB#" << A->getNumber() - << " -- BB#" << NewNum + << " -- BB#" << NMBB->getNumber() << " -- BB#" << B->getNumber() << '\n'); A->ReplaceUsesOfBlockWith(B, NMBB); From daniel at zuster.org Thu Nov 12 14:53:56 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 20:53:56 -0000 Subject: [llvm-commits] [llvm] r87025 - /llvm/trunk/include/llvm/Value.h Message-ID: <200911122053.nACKrujJ008914@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 12 14:53:56 2009 New Revision: 87025 URL: http://llvm.org/viewvc/llvm-project?rev=87025&view=rev Log: Attempt to unbreak LLVM build, David G. please check. Modified: llvm/trunk/include/llvm/Value.h Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=87025&r1=87024&r2=87025&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Thu Nov 12 14:53:56 2009 @@ -224,6 +224,7 @@ NamedMDNodeVal, // This is an instance of NamedMDNode InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue + FixedStackPseudoSourceValueVal, // This is an instance of PseudoSourceValue InstructionVal, // This is an instance of Instruction // Markers: From greened at obbligato.org Thu Nov 12 14:55:29 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 20:55:29 -0000 Subject: [llvm-commits] [llvm] r87026 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h Message-ID: <200911122055.nACKtTGj008965@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 14:55:29 2009 New Revision: 87026 URL: http://llvm.org/viewvc/llvm-project?rev=87026&view=rev Log: Add hasLoadFromStackSlot and hasStoreToStackSlot to return whether a machine instruction loads or stores from/to a stack slot. Unlike isLoadFromStackSlot and isStoreFromStackSlot, the instruction may be something other than a pure load/store (e.g. it may be an arithmetic operation with a memory operand). This helps AsmPrinter determine when to print a spill/reload comment. This is only a hint since we may not be able to figure this out in all cases. As such, it should not be relied upon for correctness. Implement for X86. Return false by default for other architectures. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=87026&r1=87025&r2=87026&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Thu Nov 12 14:55:29 2009 @@ -170,6 +170,17 @@ int &FrameIndex) const { return 0; } + + /// hasLoadFromStackSlot - If the specified machine instruction has + /// a load from a stack slot, return true along with the FrameIndex + /// of the loaded stack slot. If not, return false. Unlike + /// isLoadFromStackSlot, this returns true for any instructions that + /// loads from the stack. This is just a hint, as some cases may be + /// missed. + virtual bool hasLoadFromStackSlot(const MachineInstr *MI, + int &FrameIndex) const { + return 0; + } /// isStoreToStackSlot - If the specified machine instruction is a direct /// store to a stack slot, return the virtual or physical register number of @@ -181,6 +192,17 @@ return 0; } + /// hasStoreToStackSlot - If the specified machine instruction has a + /// store to a stack slot, return true along with the FrameIndex of + /// the loaded stack slot. If not, return false. Unlike + /// isStoreToStackSlot, this returns true for any instructions that + /// loads from the stack. This is just a hint, as some cases may be + /// missed. + virtual bool hasStoreToStackSlot(const MachineInstr *MI, + int &FrameIndex) const { + return 0; + } + /// reMaterialize - Re-issue the specified 'original' instruction at the /// specific location targeting a new destination register. virtual void reMaterialize(MachineBasicBlock &MBB, Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=87026&r1=87025&r2=87026&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Nov 12 14:55:29 2009 @@ -26,11 +26,15 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/LiveVariables.h" +#include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetOptions.h" #include "llvm/MC/MCAsmInfo.h" + +#include + using namespace llvm; static cl::opt @@ -707,6 +711,21 @@ } } +/// isFrameOperand - Return true and the FrameIndex if the specified +/// operand and follow operands form a reference to the stack frame. +bool X86InstrInfo::isFrameOperand(const MachineInstr *MI, unsigned int Op, + int &FrameIndex) const { + if (MI->getOperand(Op).isFI() && MI->getOperand(Op+1).isImm() && + MI->getOperand(Op+2).isReg() && MI->getOperand(Op+3).isImm() && + MI->getOperand(Op+1).getImm() == 1 && + MI->getOperand(Op+2).getReg() == 0 && + MI->getOperand(Op+3).getImm() == 0) { + FrameIndex = MI->getOperand(Op).getIndex(); + return true; + } + return false; +} + unsigned X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const { switch (MI->getOpcode()) { @@ -723,19 +742,32 @@ case X86::MOVDQArm: case X86::MMX_MOVD64rm: case X86::MMX_MOVQ64rm: - if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && - MI->getOperand(3).isReg() && MI->getOperand(4).isImm() && - MI->getOperand(2).getImm() == 1 && - MI->getOperand(3).getReg() == 0 && - MI->getOperand(4).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); + if (isFrameOperand(MI, 1, FrameIndex)) { return MI->getOperand(0).getReg(); } + // Check for post-frame index elimination operations + return hasLoadFromStackSlot(MI, FrameIndex); break; } return 0; } +bool X86InstrInfo::hasLoadFromStackSlot(const MachineInstr *MI, + int &FrameIndex) const { + for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), + oe = MI->memoperands_end(); + o != oe; + ++o) { + if ((*o)->isLoad() && (*o)->getValue()) + if (const FixedStackPseudoSourceValue *Value = + dyn_cast((*o)->getValue())) { + FrameIndex = Value->getFrameIndex(); + return true; + } + } + return false; +} + unsigned X86InstrInfo::isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const { switch (MI->getOpcode()) { @@ -753,19 +785,32 @@ case X86::MMX_MOVD64mr: case X86::MMX_MOVQ64mr: case X86::MMX_MOVNTQmr: - if (MI->getOperand(0).isFI() && MI->getOperand(1).isImm() && - MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && - MI->getOperand(1).getImm() == 1 && - MI->getOperand(2).getReg() == 0 && - MI->getOperand(3).getImm() == 0) { - FrameIndex = MI->getOperand(0).getIndex(); + if (isFrameOperand(MI, 0, FrameIndex)) { return MI->getOperand(X86AddrNumOperands).getReg(); } + // Check for post-frame index elimination operations + return hasStoreToStackSlot(MI, FrameIndex); break; } return 0; } +bool X86InstrInfo::hasStoreToStackSlot(const MachineInstr *MI, + int &FrameIndex) const { + for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), + oe = MI->memoperands_end(); + o != oe; + ++o) { + if ((*o)->isStore() && (*o)->getValue()) + if (const FixedStackPseudoSourceValue *Value = + dyn_cast((*o)->getValue())) { + FrameIndex = Value->getFrameIndex(); + return true; + } + } + return false; +} + /// regIsPICBase - Return true if register is PIC base (i.e.g defined by /// X86::MOVPC32r. static bool regIsPICBase(unsigned BaseReg, const MachineRegisterInfo &MRI) { Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=87026&r1=87025&r2=87026&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Thu Nov 12 14:55:29 2009 @@ -449,8 +449,25 @@ unsigned &SrcSubIdx, unsigned &DstSubIdx) const; unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; + + /// hasLoadFromStackSlot - If the specified machine instruction has + /// a load from a stack slot, return true along with the FrameIndex + /// of the loaded stack slot. If not, return false. Unlike + /// isLoadFromStackSlot, this returns true for any instructions that + /// loads from the stack. This is a hint only and may not catch all + /// cases. + bool hasLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; + unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; + /// hasStoreToStackSlot - If the specified machine instruction has a + /// store to a stack slot, return true along with the FrameIndex of + /// the loaded stack slot. If not, return false. Unlike + /// isStoreToStackSlot, this returns true for any instructions that + /// loads from the stack. This is a hint only and may not catch all + /// cases. + bool hasStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; + bool isReallyTriviallyReMaterializable(const MachineInstr *MI, AliasAnalysis *AA) const; void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, @@ -610,6 +627,11 @@ unsigned OpNum, const SmallVectorImpl &MOs, unsigned Size, unsigned Alignment) const; + + /// isFrameOperand - Return true and the FrameIndex if the specified + /// operand and follow operands form a reference to the stack frame. + bool isFrameOperand(const MachineInstr *MI, unsigned int Op, + int &FrameIndex) const; }; } // End llvm namespace From evan.cheng at apple.com Thu Nov 12 14:58:27 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 12:58:27 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: <001636ed6e725660440478316be4@google.com> References: <001636ed6e725660440478316be4@google.com> Message-ID: <15FDCBA0-9F85-461B-A0F4-7381A426FFFD@apple.com> Looks good. The only comment apart from Dan and Anton's comments is to force large code model for Darwin x86_64 as well unless explicitly specified otherwise. Eric, please make sure large code model JIT works on Mac OS X. Evan On Nov 12, 2009, at 11:19 AM, jyasskin at gmail.com wrote: > Reviewers: gohman_apple.com, > > Message: > Patch at http://codereview.appspot.com/download/issue154066_1033.diff > > I'm unfamiliar with the code generator, so please go over that part of > the change with a fine-toothed comb. > > This patch doesn't include r86941, assuming that'll be rolled back > temporarily. > > Description: > The large code model is documented at > http://www.x86-64.org/documentation/abi.pdf and says that calls should > assume their target doesn't live within the 32-bit pc-relative offset > that fits in the call instruction. > > The best fix, turning off the global-address->target-global-address > conversion in X86TargetLowering::LowerCall(), breaks the lazy JIT > because it can separate the movabs(imm->reg) from the actual call > instruction. The lazy JIT receives the address of the movabs as a > relocation and needs to record the return address from the call; and > then when that call happens, it needs to patch the movabs with the > newly-compiled target. We could thread the call instruction into the > relocation and record the movabs<->call mapping explicitly, but that > seems to require at least as much new complication in the code > generator > as this change. > > The second attempt defined a new CALL64i pseudo-instruction, which > expanded to a 2-instruction sequence in the assembly output and was > special-cased in the X86CodeEmitter's emitInstruction() function. That > breaks indirect calls, which stop using distinct stubs for each > lazily-compiled function. > > The third attempt goes back to the first approach but makes lazy > functions _always_ go through a call stub. This works. You'd think > we'd > only have to force lazy calls through a stub on difficult platforms, > but > that turns out to break indirect calls through a function pointer. The > right fix for that is to distinguish between calls and address-of > operations on uncompiled functions, but that's complex enough to leave > for someone else to do. > > Please review this at http://codereview.appspot.com/154066 > > Affected files: > M lib/ExecutionEngine/JIT/JITEmitter.cpp > M lib/Target/X86/X86CodeEmitter.cpp > M lib/Target/X86/X86ISelLowering.cpp > M lib/Target/X86/X86JITInfo.cpp > M test/ExecutionEngine/stubs.ll > M test/Makefile > M unittests/ExecutionEngine/JIT/JITTest.cpp > M utils/lit/TestFormats.py > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From greened at obbligato.org Thu Nov 12 15:00:04 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 21:00:04 -0000 Subject: [llvm-commits] [llvm] r87027 - in /llvm/trunk: include/llvm/Target/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ Message-ID: <200911122100.nACL04kl009132@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 15:00:03 2009 New Revision: 87027 URL: http://llvm.org/viewvc/llvm-project?rev=87027&view=rev Log: Make the MachineFunction argument of getFrameRegister const. This also fixes a build error. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.h llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h llvm/trunk/lib/Target/Mips/MipsRegisterInfo.h llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.h llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.cpp llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.h llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h llvm/trunk/lib/Target/X86/X86RegisterInfo.h llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -275,6 +275,7 @@ regclass_iterator RegClassBegin, RegClassEnd; // List of regclasses int CallFrameSetupOpcode, CallFrameDestroyOpcode; + protected: TargetRegisterInfo(const TargetRegisterDesc *D, unsigned NR, regclass_iterator RegClassBegin, @@ -684,7 +685,7 @@ /// getFrameRegister - This method should return the register used as a base /// for values allocated in the current stack frame. - virtual unsigned getFrameRegister(MachineFunction &MF) const = 0; + virtual unsigned getFrameRegister(const MachineFunction &MF) const = 0; /// getFrameIndexOffset - Returns the displacement from the frame register to /// the stack frame of the specified index. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -105,7 +105,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; // Exception handling queries. unsigned getEHExceptionRegister() const; Modified: llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp Thu Nov 12 15:00:03 2009 @@ -314,7 +314,7 @@ return 0; } -unsigned AlphaRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned AlphaRegisterInfo::getFrameRegister(const MachineFunction &MF) const { return hasFP(MF) ? Alpha::R15 : Alpha::R30; } Modified: llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.h (original) +++ llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -52,7 +52,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; // Exception handling queries. unsigned getEHExceptionRegister() const; Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -76,7 +76,7 @@ void emitPrologue(MachineFunction &MF) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; unsigned getRARegister() const; // Exception handling queries. Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Thu Nov 12 15:00:03 2009 @@ -596,7 +596,7 @@ } unsigned -SPURegisterInfo::getFrameRegister(MachineFunction &MF) const +SPURegisterInfo::getFrameRegister(const MachineFunction &MF) const { return SPU::R1; } Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -78,7 +78,7 @@ //! Get return address register (LR, aka R0) unsigned getRARegister() const; //! Get the stack frame register (SP, aka R1) - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; //! Perform target-specific stack frame setup. void getInitialFrameState(std::vector &Moves) const; Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -60,7 +60,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; //! Get DWARF debugging register number int getDwarfRegNum(unsigned RegNum, bool isEH) const; Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.h (original) +++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -65,7 +65,7 @@ /// Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; /// Exception handling queries. unsigned getEHExceptionRegister() const; Modified: llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.cpp?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.cpp Thu Nov 12 15:00:03 2009 @@ -72,7 +72,7 @@ return -1; } -unsigned PIC16RegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned PIC16RegisterInfo::getFrameRegister(const MachineFunction &MF) const { llvm_unreachable("PIC16 Does not have any frame register"); return 0; } Modified: llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16RegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -59,7 +59,7 @@ virtual void emitPrologue(MachineFunction &MF) const; virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; virtual int getDwarfRegNum(unsigned RegNum, bool isEH) const; - virtual unsigned getFrameRegister(MachineFunction &MF) const; + virtual unsigned getFrameRegister(const MachineFunction &MF) const; virtual unsigned getRARegister() const; }; Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -83,7 +83,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; void getInitialFrameState(std::vector &Moves) const; // Exception handling queries. Modified: llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.cpp?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.cpp Thu Nov 12 15:00:03 2009 @@ -175,7 +175,7 @@ return SP::I7; } -unsigned SparcRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned SparcRegisterInfo::getFrameRegister(const MachineFunction &MF) const { return SP::I6; } Modified: llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.h (original) +++ llvm/trunk/lib/Target/Sparc/SparcRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -54,7 +54,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; // Exception handling queries. unsigned getEHExceptionRegister() const; Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp Thu Nov 12 15:00:03 2009 @@ -320,7 +320,8 @@ return 0; } -unsigned SystemZRegisterInfo::getFrameRegister(MachineFunction &MF) const { +unsigned +SystemZRegisterInfo::getFrameRegister(const MachineFunction &MF) const { assert(0 && "What is the frame register"); return 0; } Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -68,7 +68,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; // Exception handling queries. unsigned getEHExceptionRegister() const; Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -153,7 +153,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; int getFrameIndexOffset(MachineFunction &MF, int FI) const; void getInitialFrameState(std::vector &Moves) const; Modified: llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.h?rev=87027&r1=87026&r2=87027&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.h (original) +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.h Thu Nov 12 15:00:03 2009 @@ -60,7 +60,7 @@ unsigned eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, int *Value = NULL, RegScavenger *RS = NULL) const; - + void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS = NULL) const; @@ -71,7 +71,7 @@ // Debug information queries. unsigned getRARegister() const; - unsigned getFrameRegister(MachineFunction &MF) const; + unsigned getFrameRegister(const MachineFunction &MF) const; void getInitialFrameState(std::vector &Moves) const; //! Return the array of argument passing registers From greened at obbligato.org Thu Nov 12 15:04:20 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 21:04:20 -0000 Subject: [llvm-commits] [llvm] r87028 - /llvm/trunk/include/llvm/Value.h Message-ID: <200911122104.nACL4KeC009301@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 15:04:19 2009 New Revision: 87028 URL: http://llvm.org/viewvc/llvm-project?rev=87028&view=rev Log: Fix a build error by providing a missing enum value. Modified: llvm/trunk/include/llvm/Value.h Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=87028&r1=87027&r2=87028&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Thu Nov 12 15:04:19 2009 @@ -226,7 +226,9 @@ PseudoSourceValueVal, // This is an instance of PseudoSourceValue FixedStackPseudoSourceValueVal, // This is an instance of PseudoSourceValue InstructionVal, // This is an instance of Instruction - + FixedStackPseudoSourceValueVal, // This is an instance of + // FixedStackPseudoSourceValue + // Markers: ConstantFirstVal = FunctionVal, ConstantLastVal = ConstantPointerNullVal From anton at korobeynikov.info Thu Nov 12 15:06:56 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 13 Nov 2009 00:06:56 +0300 Subject: [llvm-commits] [llvm] r87028 - /llvm/trunk/include/llvm/Value.h In-Reply-To: <200911122104.nACL4KeC009301@zion.cs.uiuc.edu> References: <200911122104.nACL4KeC009301@zion.cs.uiuc.edu> Message-ID: Hello, David > @@ -226,7 +226,9 @@ > ? ? PseudoSourceValueVal, ? ? // This is an instance of PseudoSourceValue > ? ? FixedStackPseudoSourceValueVal, // This is an instance of PseudoSourceValue > ? ? InstructionVal, ? ? ? ? ? // This is an instance of Instruction > - > + ? ?FixedStackPseudoSourceValueVal, // This is an instance of > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// FixedStackPseudoSourceValue > + Sounds like duplicate enum value. Please check before commit :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From daniel at zuster.org Thu Nov 12 15:07:02 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 21:07:02 -0000 Subject: [llvm-commits] [llvm] r87029 - /llvm/trunk/include/llvm/Value.h Message-ID: <200911122107.nACL72bx009425@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 12 15:07:02 2009 New Revision: 87029 URL: http://llvm.org/viewvc/llvm-project?rev=87029&view=rev Log: Remove my Value.h build fix. Modified: llvm/trunk/include/llvm/Value.h Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=87029&r1=87028&r2=87029&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Thu Nov 12 15:07:02 2009 @@ -224,7 +224,6 @@ NamedMDNodeVal, // This is an instance of NamedMDNode InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue - FixedStackPseudoSourceValueVal, // This is an instance of PseudoSourceValue InstructionVal, // This is an instance of Instruction FixedStackPseudoSourceValueVal, // This is an instance of // FixedStackPseudoSourceValue From greened at obbligato.org Thu Nov 12 15:07:54 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 21:07:54 -0000 Subject: [llvm-commits] [llvm] r87030 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Message-ID: <200911122107.nACL7s2h009469@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 15:07:54 2009 New Revision: 87030 URL: http://llvm.org/viewvc/llvm-project?rev=87030&view=rev Log: Set the ReloadReuse AsmPrinter flag where appropriate. Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=87030&r1=87029&r2=87030&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Nov 12 15:07:54 2009 @@ -1704,6 +1704,7 @@ // Mark is killed. MachineInstr *CopyMI = prior(InsertLoc); + CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); MachineOperand *KillOpnd = CopyMI->findRegisterUseOperand(InReg); KillOpnd->setIsKill(); UpdateKills(*CopyMI, TRI, RegKills, KillOps); @@ -1984,6 +1985,7 @@ TII->copyRegToReg(MBB, InsertLoc, DesignatedReg, PhysReg, RC, RC); MachineInstr *CopyMI = prior(InsertLoc); + CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); UpdateKills(*CopyMI, TRI, RegKills, KillOps); // This invalidates DesignatedReg. @@ -2112,6 +2114,7 @@ // virtual or needing to clobber any values if it's physical). NextMII = &MI; --NextMII; // backtrack to the copy. + NextMII->setAsmPrinterFlag(AsmPrinter::ReloadReuse); // Propagate the sub-register index over. if (SubIdx) { DefMO = NextMII->findRegisterDefOperand(DestReg); From dag at cray.com Thu Nov 12 15:09:08 2009 From: dag at cray.com (David Greene) Date: Thu, 12 Nov 2009 15:09:08 -0600 Subject: [llvm-commits] [llvm] r87028 - /llvm/trunk/include/llvm/Value.h In-Reply-To: References: <200911122104.nACL4KeC009301@zion.cs.uiuc.edu> Message-ID: <200911121509.08278.dag@cray.com> On Thursday 12 November 2009 15:06, you wrote: > Hello, David > > > @@ -226,7 +226,9 @@ > > ? ? PseudoSourceValueVal, ? ? // This is an instance of PseudoSourceValue > > ? ? FixedStackPseudoSourceValueVal, // This is an instance of > > PseudoSourceValue InstructionVal, ? ? ? ? ? // This is an instance of > > Instruction - > > + ? ?FixedStackPseudoSourceValueVal, // This is an instance of > > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// FixedStackPseudoSourceValue > > + > > Sounds like duplicate enum value. Please check before commit :) Aw %&$&! :) It wasn't there before, honest! Will fix. -Dave From dag at cray.com Thu Nov 12 15:10:32 2009 From: dag at cray.com (David Greene) Date: Thu, 12 Nov 2009 15:10:32 -0600 Subject: [llvm-commits] [llvm] r87029 - /llvm/trunk/include/llvm/Value.h In-Reply-To: <200911122107.nACL72bx009425@zion.cs.uiuc.edu> References: <200911122107.nACL72bx009425@zion.cs.uiuc.edu> Message-ID: <200911121510.32704.dag@cray.com> On Thursday 12 November 2009 15:07, Daniel Dunbar wrote: > Author: ddunbar > Date: Thu Nov 12 15:07:02 2009 > New Revision: 87029 > > URL: http://llvm.org/viewvc/llvm-project?rev=87029&view=rev > Log: > Remove my Value.h build fix. Thanks. Your editor is quicker than mine. :) -Dave From gohman at apple.com Thu Nov 12 15:19:09 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Nov 2009 13:19:09 -0800 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <291C756E-2006-4E03-B4B7-150136242E11@gmail.com> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> <4AFBD9EA.4040907@free.fr> <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> <4AFC61AC.8080806@free.fr> <291C756E-2006-4E03-B4B7-150136242E11@gmail.com> Message-ID: <0FE16449-8429-4D18-8E7D-545DBD67CFE1@apple.com> On Nov 12, 2009, at 11:36 AM, Bill Wendling wrote: > On Nov 12, 2009, at 11:27 AM, Duncan Sands wrote: > >> A call can be "nounwind" without the >> callee necessarily being nounwind. Your patch only catches the case of the >> callee being nounwind. The CallSite doesNotThrow method checks for both of >> these possibilities. I think what should happen is: at the moment of lowering >> the IR to SDAG nodes, check "doesNotThrow" on calls and set a corresponding >> flag in the SDAG node. Check this flag when outputting the dwarf table. > > Possible. Though at the point of DWARF generation, we don't have the SDAG nodes anymore. So it would have to be propagated to the CALL instruction. Crazy idea: would it make sense to extend MachineMemOperand to be able to describe which Function is being called in a call MachineInstr? Dan From daniel at zuster.org Thu Nov 12 15:26:12 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 21:26:12 -0000 Subject: [llvm-commits] [llvm] r87031 - /llvm/trunk/include/llvm/ADT/StringRef.h Message-ID: <200911122126.nACLQCGs010192@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 12 15:26:11 2009 New Revision: 87031 URL: http://llvm.org/viewvc/llvm-project?rev=87031&view=rev Log: StringRef(const char*) should not be used to turn null pointers into empty strings. Modified: llvm/trunk/include/llvm/ADT/StringRef.h Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=87031&r1=87030&r2=87031&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 15:26:11 2009 @@ -46,7 +46,7 @@ /// Construct a string ref from a cstring. /*implicit*/ StringRef(const char *Str) - : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; } + : Data(Str), Length(::strlen(Str)) {} /// Construct a string ref from a pointer and length. /*implicit*/ StringRef(const char *data, size_t length) From clattner at apple.com Thu Nov 12 15:35:26 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 13:35:26 -0800 Subject: [llvm-commits] [llvm] r87019 - in /llvm/trunk: include/llvm/CodeGen/PseudoSourceValue.h lib/CodeGen/PseudoSourceValue.cpp In-Reply-To: <200911122025.nACKP7We007698@zion.cs.uiuc.edu> References: <200911122025.nACKP7We007698@zion.cs.uiuc.edu> Message-ID: <6615EC3B-2F24-49F8-AE3D-8466C76B7B25@apple.com> On Nov 12, 2009, at 12:25 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 14:25:07 2009 > New Revision: 87019 > > URL: http://llvm.org/viewvc/llvm-project?rev=87019&view=rev > Log: > > Make FixedStackPseudoSourceValue a first-class PseudoSourceValue by > making it visible to clients and adding LLVM-style cast capability. > This will be used by AsmPrinter to determine when to emit spill > comments > for an instruction. Thanks David, Plaese move the printCustom method out of line, this will remove the need for the raw_ostream #include and give the class an out-of-line virtual method. Also, please use () instead of (void). -Chris > > Modified: > llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h > llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=87019&r1=87018&r2=87019&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) > +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Thu Nov 12 > 14:25:07 2009 > @@ -15,6 +15,7 @@ > #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H > > #include "llvm/Value.h" > +#include "llvm/Support/raw_ostream.h" > > namespace llvm { > class MachineFrameInfo; > @@ -32,7 +33,7 @@ > virtual void printCustom(raw_ostream &O) const; > > public: > - PseudoSourceValue(); > + PseudoSourceValue(enum ValueTy Subclass = PseudoSourceValueVal); > > /// isConstant - Test whether the memory pointed to by this > /// PseudoSourceValue has a constant value. > @@ -76,6 +77,38 @@ > /// constant, this doesn't need to identify a specific jump table. > static const PseudoSourceValue *getJumpTable(); > }; > + > + /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue > + /// for holding FixedStack values, which must include a frame > + /// index. > + class FixedStackPseudoSourceValue : public PseudoSourceValue { > + const int FI; > + public: > + explicit FixedStackPseudoSourceValue(int fi) : > + PseudoSourceValue(FixedStackPseudoSourceValueVal), FI(fi) {} > + > + /// classof - Methods for support type inquiry through isa, > cast, and > + /// dyn_cast: > + /// > + static inline bool classof(const FixedStackPseudoSourceValue *) { > + return true; > + } > + static inline bool classof(const Value *V) { > + return V->getValueID() == FixedStackPseudoSourceValueVal; > + } > + > + virtual bool isConstant(const MachineFrameInfo *MFI) const; > + > + virtual bool isAliased(const MachineFrameInfo *MFI) const; > + > + virtual bool mayAlias(const MachineFrameInfo *) const; > + > + virtual void printCustom(raw_ostream &OS) const { > + OS << "FixedStack" << FI; > + } > + > + int getFrameIndex(void) const { return FI; } > + }; > } // End llvm namespace > > #endif > > Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=87019&r1=87018&r2=87019&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) > +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Thu Nov 12 14:25:07 > 2009 > @@ -43,35 +43,14 @@ > // Eventually these should be uniqued on LLVMContext rather than in > a managed > // static. For now, we can safely use the global context for the > time being to > // squeak by. > -PseudoSourceValue::PseudoSourceValue() : > +PseudoSourceValue::PseudoSourceValue(enum ValueTy Subclass) : > Value(Type::getInt8PtrTy(getGlobalContext()), > - PseudoSourceValueVal) {} > + Subclass) {} > > void PseudoSourceValue::printCustom(raw_ostream &O) const { > O << PSVNames[this - *PSVs]; > } > > -namespace { > - /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue > - /// for holding FixedStack values, which must include a frame > - /// index. > - class FixedStackPseudoSourceValue : public PseudoSourceValue { > - const int FI; > - public: > - explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {} > - > - virtual bool isConstant(const MachineFrameInfo *MFI) const; > - > - virtual bool isAliased(const MachineFrameInfo *MFI) const; > - > - virtual bool mayAlias(const MachineFrameInfo *) const; > - > - virtual void printCustom(raw_ostream &OS) const { > - OS << "FixedStack" << FI; > - } > - }; > -} > - > static ManagedStatic > > FSValues; > > const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From greened at obbligato.org Thu Nov 12 15:49:55 2009 From: greened at obbligato.org (David Greene) Date: Thu, 12 Nov 2009 21:49:55 -0000 Subject: [llvm-commits] [llvm] r87034 - in /llvm/trunk: include/llvm/CodeGen/PseudoSourceValue.h lib/CodeGen/PseudoSourceValue.cpp Message-ID: <200911122149.nACLntBr011167@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 15:49:55 2009 New Revision: 87034 URL: http://llvm.org/viewvc/llvm-project?rev=87034&view=rev Log: Do some cleanups suggested by Chris. Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=87034&r1=87033&r2=87034&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Thu Nov 12 15:49:55 2009 @@ -15,7 +15,6 @@ #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H #include "llvm/Value.h" -#include "llvm/Support/raw_ostream.h" namespace llvm { class MachineFrameInfo; @@ -103,11 +102,9 @@ virtual bool mayAlias(const MachineFrameInfo *) const; - virtual void printCustom(raw_ostream &OS) const { - OS << "FixedStack" << FI; - } + virtual void printCustom(raw_ostream &OS) const; - int getFrameIndex(void) const { return FI; } + int getFrameIndex() const { return FI; } }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=87034&r1=87033&r2=87034&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Thu Nov 12 15:49:55 2009 @@ -109,3 +109,7 @@ // Spill slots will not alias any LLVM IR value. return !MFI->isSpillSlotObjectIndex(FI); } + +void FixedStackPseudoSourceValue::printCustom(raw_ostream &OS) const { + OS << "FixedStack" << FI; +} From clattner at apple.com Thu Nov 12 15:53:05 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 13:53:05 -0800 Subject: [llvm-commits] [llvm] r87034 - in /llvm/trunk: include/llvm/CodeGen/PseudoSourceValue.h lib/CodeGen/PseudoSourceValue.cpp In-Reply-To: <200911122149.nACLntBr011167@zion.cs.uiuc.edu> References: <200911122149.nACLntBr011167@zion.cs.uiuc.edu> Message-ID: Thanks! On Nov 12, 2009, at 1:49 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 15:49:55 2009 > New Revision: 87034 > > URL: http://llvm.org/viewvc/llvm-project?rev=87034&view=rev > Log: > > Do some cleanups suggested by Chris. > > Modified: > llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h > llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=87034&r1=87033&r2=87034&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) > +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Thu Nov 12 > 15:49:55 2009 > @@ -15,7 +15,6 @@ > #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H > > #include "llvm/Value.h" > -#include "llvm/Support/raw_ostream.h" > > namespace llvm { > class MachineFrameInfo; > @@ -103,11 +102,9 @@ > > virtual bool mayAlias(const MachineFrameInfo *) const; > > - virtual void printCustom(raw_ostream &OS) const { > - OS << "FixedStack" << FI; > - } > + virtual void printCustom(raw_ostream &OS) const; > > - int getFrameIndex(void) const { return FI; } > + int getFrameIndex() const { return FI; } > }; > } // End llvm namespace > > > Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=87034&r1=87033&r2=87034&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) > +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Thu Nov 12 15:49:55 > 2009 > @@ -109,3 +109,7 @@ > // Spill slots will not alias any LLVM IR value. > return !MFI->isSpillSlotObjectIndex(FI); > } > + > +void FixedStackPseudoSourceValue::printCustom(raw_ostream &OS) > const { > + OS << "FixedStack" << FI; > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Thu Nov 12 15:54:01 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 13:54:01 -0800 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll In-Reply-To: <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> References: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> <4AFBBC6B.8010304@free.fr> <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> Message-ID: <6E45DF35-172E-409D-8D71-4724ED17BD31@apple.com> On Nov 12, 2009, at 10:39 AM, Dan Gohman wrote: > > On Nov 11, 2009, at 11:42 PM, Duncan Sands wrote: > >> Hi Dan, >> >>> Add support for tail duplication to BranchFolding, and extend >>> tail merging support to handle more cases. >>> - Recognize several cases where tail merging is beneficial even when >>> the tail size is smaller than the generic threshold. >>> - Make use of MachineInstrDesc::isBarrier to help detect >>> non-fallthrough blocks. >>> - Check for and avoid disrupting fall-through edges in more cases. >> >> can this result in a label being sucked off the end of a block, and >> moved into another? Exception handling labels come in pairs, and it >> would be wrong to move one of them without the other (even all the >> instructions in between). > > My understanding is that each EH_LABEL has a unique ID, and this > automatically prevents two of them from being merged. > > I just made a change to mark all label instructions as non-duplicable, > to prevent tail-duplication and other code-duplicating optimizations > from getting into trouble. Does this cause debug labels to change optimization/codegen behavior? -Chris From sabre at nondot.org Thu Nov 12 15:58:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Nov 2009 21:58:18 -0000 Subject: [llvm-commits] [llvm] r87035 - /llvm/trunk/lib/Transforms/IPO/Inliner.cpp Message-ID: <200911122158.nACLwI95011477@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 12 15:58:18 2009 New Revision: 87035 URL: http://llvm.org/viewvc/llvm-project?rev=87035&view=rev Log: use isInstructionTriviallyDead, as pointed out by Duncan Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=87035&r1=87034&r2=87035&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Nov 12 15:58:18 2009 @@ -19,10 +19,11 @@ #include "llvm/IntrinsicInst.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/InlineCost.h" -#include "llvm/Support/CallSite.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO/InlinerPass.h" #include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/Transforms/Utils/Local.h" +#include "llvm/Support/CallSite.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -344,8 +345,7 @@ // just delete the call instead of trying to inline it, regardless of // size. This happens because IPSCCP propagates the result out of the // call and then we're left with the dead call. - if (CS.getInstruction()->use_empty() && - !CS.getInstruction()->mayHaveSideEffects()) { + if (isInstructionTriviallyDead(CS.getInstruction())) { DEBUG(errs() << " -> Deleting dead call: " << *CS.getInstruction() << "\n"); // Update the call graph by deleting the edge from Callee to Caller. From isanbard at gmail.com Thu Nov 12 15:59:20 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 12 Nov 2009 21:59:20 -0000 Subject: [llvm-commits] [llvm] r87036 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfException.cpp DwarfException.h Message-ID: <200911122159.nACLxKi3011525@zion.cs.uiuc.edu> Author: void Date: Thu Nov 12 15:59:20 2009 New Revision: 87036 URL: http://llvm.org/viewvc/llvm-project?rev=87036&view=rev Log: Refactor code that checks if it's a call to a "nounwind" function. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=87036&r1=87035&r2=87036&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Thu Nov 12 15:59:20 2009 @@ -462,6 +462,40 @@ return SizeActions; } +/// CallToNoUnwindFunction - Return `true' if this is a call to a function +/// marked `nounwind'. Return `false' otherwise. +bool DwarfException::CallToNoUnwindFunction(const MachineInstr *MI) { + assert(MI->getDesc().isCall() && "This should be a call instruction!"); + + bool MarkedNoUnwind = false; + bool SawFunc = false; + + for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) { + const MachineOperand &MO = MI->getOperand(I); + + if (MO.isGlobal()) { + if (Function *F = dyn_cast(MO.getGlobal())) { + if (SawFunc) { + // Be conservative. If we have more than one function operand for this + // call, then we can't make the assumption that it's the callee and + // not a parameter to the call. + // + // FIXME: Determine if there's a way to say that `F' is the callee or + // parameter. + MarkedNoUnwind = false; + break; + } + if (F->doesNotThrow()) { + SawFunc = true; + MarkedNoUnwind = true; + } + } + } + } + + return MarkedNoUnwind; +} + /// ComputeCallSiteTable - Compute the call-site table. The entry for an invoke /// has a try-range containing the call, a non-zero landing pad, and an /// appropriate action. The entry for an ordinary call has a try-range @@ -490,37 +524,8 @@ for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end(); MI != E; ++MI) { if (!MI->isLabel()) { - if (MI->getDesc().isCall()) { - // Don't mark a call as potentially throwing if the function it's - // calling is marked "nounwind". - bool DoesNotThrow = false; - bool SawFunc = false; - for (unsigned OI = 0, OE = MI->getNumOperands(); OI != OE; ++OI) { - const MachineOperand &MO = MI->getOperand(OI); - - if (MO.isGlobal()) { - if (Function *F = dyn_cast(MO.getGlobal())) { - if (SawFunc) { - // Be conservative. If we have more than one function operand - // for this call, then we can't make the assumption that it's - // the callee and not a parameter to the call. - // - // FIXME: Determine if there's a way to say that `F' is the - // callee or parameter. - DoesNotThrow = false; - break; - } - if (F->doesNotThrow()) { - SawFunc = true; - DoesNotThrow = true; - } - } - } - } - - if (!DoesNotThrow) - SawPotentiallyThrowing = true; - } + if (MI->getDesc().isCall()) + SawPotentiallyThrowing |= !CallToNoUnwindFunction(MI); continue; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=87036&r1=87035&r2=87036&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Thu Nov 12 15:59:20 2009 @@ -155,6 +155,10 @@ SmallVectorImpl &Actions, SmallVectorImpl &FirstActions); + /// CallToNoUnwindFunction - Return `true' if this is a call to a function + /// marked `nounwind'. Return `false' otherwise. + bool CallToNoUnwindFunction(const MachineInstr *MI); + /// ComputeCallSiteTable - Compute the call-site table. The entry for an /// invoke has a try-range containing the call, a non-zero landing pad and an /// appropriate action. The entry for an ordinary call has a try-range From jyasskin at google.com Thu Nov 12 16:35:43 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Thu, 12 Nov 2009 14:35:43 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> References: <001636ed6e725660440478316be4@google.com> <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> Message-ID: On Thu, Nov 12, 2009 at 11:46 AM, Dan Gohman wrote: > In the X86ISelLowering.cpp part, disabling the special handling > for GlobalAddresses and ExternalSymbols is fine, but the way the > proposed patch does that also happens to disable the > "else if (isTailCall)" code immediately below that, which handles > indirect tail calls. That code is still needed in the large code > model -- the callee needs to be in a specific physical register > so that it can survive the epilogue. Oh, right. New version of the patch at http://codereview.appspot.com/154066 / http://codereview.appspot.com/download/issue154066_23.diff On Thu, Nov 12, 2009 at 12:10 PM, Anton Korobeynikov wrote: > Also, the check for Is64Bit seems to be redundant - the codemodel > setting is valid only in 64 bit mode, thus "large code model" and > 32-bit code is undefined :) Oh! Ok. I don't see that actually enforced anywhere so I replaced the check with an assert instead of omitting it entirely. On Thu, Nov 12, 2009 at 12:58 PM, Evan Cheng wrote: > Looks good. The only comment apart from Dan and Anton's comments is to > force large code model for Darwin x86_64 as well unless explicitly > specified otherwise. That looks like an change in X86TargetMachine::addCodeEmitter()? Am I going to break anything if I leave that change to a separate commit? Since I don't have a Darwin x86_64 system, I'd rather have one of you guys make that change if possible. > Eric, please make sure large code model JIT works on Mac OS X. From isanbard at gmail.com Thu Nov 12 17:13:08 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 12 Nov 2009 23:13:08 -0000 Subject: [llvm-commits] [llvm] r87040 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <200911122313.nACND8V1014122@zion.cs.uiuc.edu> Author: void Date: Thu Nov 12 17:13:08 2009 New Revision: 87040 URL: http://llvm.org/viewvc/llvm-project?rev=87040&view=rev Log: Simplify code a bit Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=87040&r1=87039&r2=87040&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Thu Nov 12 17:13:08 2009 @@ -485,10 +485,9 @@ MarkedNoUnwind = false; break; } - if (F->doesNotThrow()) { - SawFunc = true; - MarkedNoUnwind = true; - } + + MarkedNoUnwind = F->doesNotThrow(); + SawFunc = true; } } } From resistor at mac.com Thu Nov 12 17:22:41 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 12 Nov 2009 23:22:41 -0000 Subject: [llvm-commits] [llvm] r87042 - /llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp Message-ID: <200911122322.nACNMfH8014530@zion.cs.uiuc.edu> Author: resistor Date: Thu Nov 12 17:22:41 2009 New Revision: 87042 URL: http://llvm.org/viewvc/llvm-project?rev=87042&view=rev Log: Re-enable this code, since redundant PHIs are now being better nuked. Modified: llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp?rev=87042&r1=87041&r2=87042&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp Thu Nov 12 17:22:41 2009 @@ -629,9 +629,6 @@ } } - // FIXME: This code is commented out for now, because it can lead to the - // insertion of a lot of redundant PHIs being inserted by SSAUpdater. -#if 0 // Perform a forward data-flow to compute availability at all points on // the CFG. do { @@ -709,7 +706,6 @@ CurInst->eraseFromParent(); } } -#endif VT.clear(); for (DenseMap::iterator From jyasskin at gmail.com Thu Nov 12 17:34:58 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Thu, 12 Nov 2009 23:34:58 +0000 Subject: [llvm-commits] [PATCH] Move stub allocation to the JITEmitter Message-ID: <0016e6470f36c55e08047834fde7@google.com> Reviewers: echristo_apple.com, Message: This overlaps with http://codereview.appspot.com/154066 (far calls in x86 large code model) some; I'll merge whichever gets committed second. I got nlewycky to confirm that the re-enabled tests do actually pass on arm and ppc. Description: * Move stub allocation inside the JITEmitter, instead of exposing a way for each TargetJITInfo subclass to allocate its own stubs. This means stubs aren't as exactly-sized anymore, but it lets us get rid of TargetJITInfo::emitFunctionStubAtAddr(), which lets ARM and PPC support the eager JIT, fixing http://llvm.org/PR4816. * Rename the JITEmitter's stub creation functions to describe the kind of stub they create. So far, all of them create lazy-compilation stubs, but they sometimes get used when far-call stubs are needed. That'll be fixed in a future patch. Please review this at http://codereview.appspot.com/153044 Affected files: M include/llvm/CodeGen/JITCodeEmitter.h M include/llvm/Target/TargetJITInfo.h M lib/ExecutionEngine/JIT/JITEmitter.cpp M lib/Target/ARM/ARMJITInfo.cpp M lib/Target/ARM/ARMJITInfo.h M lib/Target/Alpha/AlphaJITInfo.cpp M lib/Target/Alpha/AlphaJITInfo.h M lib/Target/PowerPC/PPCJITInfo.cpp M lib/Target/PowerPC/PPCJITInfo.h M lib/Target/X86/X86JITInfo.cpp M lib/Target/X86/X86JITInfo.h M unittests/ExecutionEngine/JIT/JITTest.cpp From daniel at zuster.org Thu Nov 12 18:26:26 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 16:26:26 -0800 Subject: [llvm-commits] [llvm] r87030 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp In-Reply-To: <200911122107.nACL7s2h009469@zion.cs.uiuc.edu> References: <200911122107.nACL7s2h009469@zion.cs.uiuc.edu> Message-ID: <6a8523d60911121626u1a43d64av5fe3de121890a091@mail.gmail.com> Hi David, I think something in this commit sequence broke things, the buildbots are failing everywhere. I'm going to revert-crazy as soon as I figure out what to revert unless you beat me to it with a fix. :) - Daniel On Thu, Nov 12, 2009 at 1:07 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 15:07:54 2009 > New Revision: 87030 > > URL: http://llvm.org/viewvc/llvm-project?rev=87030&view=rev > Log: > > Set the ReloadReuse AsmPrinter flag where appropriate. > > Modified: > ? ?llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp > > Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=87030&r1=87029&r2=87030&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) > +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Nov 12 15:07:54 2009 > @@ -1704,6 +1704,7 @@ > > ? ? ? ? ? ? // Mark is killed. > ? ? ? ? ? ? MachineInstr *CopyMI = prior(InsertLoc); > + ? ? ? ? ? ?CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); > ? ? ? ? ? ? MachineOperand *KillOpnd = CopyMI->findRegisterUseOperand(InReg); > ? ? ? ? ? ? KillOpnd->setIsKill(); > ? ? ? ? ? ? UpdateKills(*CopyMI, TRI, RegKills, KillOps); > @@ -1984,6 +1985,7 @@ > ? ? ? ? ? TII->copyRegToReg(MBB, InsertLoc, DesignatedReg, PhysReg, RC, RC); > > ? ? ? ? ? MachineInstr *CopyMI = prior(InsertLoc); > + ? ? ? ? ?CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); > ? ? ? ? ? UpdateKills(*CopyMI, TRI, RegKills, KillOps); > > ? ? ? ? ? // This invalidates DesignatedReg. > @@ -2112,6 +2114,7 @@ > ? ? ? ? ? ? ? ? // virtual or needing to clobber any values if it's physical). > ? ? ? ? ? ? ? ? NextMII = &MI; > ? ? ? ? ? ? ? ? --NextMII; ?// backtrack to the copy. > + ? ? ? ? ? ? ? ?NextMII->setAsmPrinterFlag(AsmPrinter::ReloadReuse); > ? ? ? ? ? ? ? ? // Propagate the sub-register index over. > ? ? ? ? ? ? ? ? if (SubIdx) { > ? ? ? ? ? ? ? ? ? DefMO = NextMII->findRegisterDefOperand(DestReg); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From evan.cheng at apple.com Thu Nov 12 18:29:11 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 16:29:11 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: References: <001636ed6e725660440478316be4@google.com> <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> Message-ID: <5A7C01CA-06E4-46EC-AA56-DBDFDBF92B5D@apple.com> On Nov 12, 2009, at 2:35 PM, Jeffrey Yasskin wrote: > On Thu, Nov 12, 2009 at 11:46 AM, Dan Gohman wrote: >> In the X86ISelLowering.cpp part, disabling the special handling >> for GlobalAddresses and ExternalSymbols is fine, but the way the >> proposed patch does that also happens to disable the >> "else if (isTailCall)" code immediately below that, which handles >> indirect tail calls. That code is still needed in the large code >> model -- the callee needs to be in a specific physical register >> so that it can survive the epilogue. > > Oh, right. New version of the patch at > http://codereview.appspot.com/154066 / > http://codereview.appspot.com/download/issue154066_23.diff > > On Thu, Nov 12, 2009 at 12:10 PM, Anton Korobeynikov > wrote: >> Also, the check for Is64Bit seems to be redundant - the codemodel >> setting is valid only in 64 bit mode, thus "large code model" and >> 32-bit code is undefined :) > > Oh! Ok. I don't see that actually enforced anywhere so I replaced the > check with an assert instead of omitting it entirely. > > On Thu, Nov 12, 2009 at 12:58 PM, Evan Cheng > wrote: >> Looks good. The only comment apart from Dan and Anton's comments is >> to >> force large code model for Darwin x86_64 as well unless explicitly >> specified otherwise. > > That looks like an change in X86TargetMachine::addCodeEmitter()? Am I > going to break anything if I leave that change to a separate commit? > Since I don't have a Darwin x86_64 system, I'd rather have one of you > guys make that change if possible. Yes. Eric should make that change. Evan > >> Eric, please make sure large code model JIT works on Mac OS X. From greened at obbligato.org Thu Nov 12 18:29:53 2009 From: greened at obbligato.org (David Greene) Date: Fri, 13 Nov 2009 00:29:53 -0000 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h Message-ID: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> Author: greened Date: Thu Nov 12 18:29:53 2009 New Revision: 87047 URL: http://llvm.org/viewvc/llvm-project?rev=87047&view=rev Log: Fix a bootstrap failure. Provide special isLoadFromStackSlotPostFE and isStoreToStackSlotPostFE interfaces to explicitly request checking for post-frame ptr elimination operands. This uses a heuristic so it isn't reliable for correctness. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=87047&r1=87046&r2=87047&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Thu Nov 12 18:29:53 2009 @@ -171,6 +171,14 @@ return 0; } + /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination + /// stack locations as well. This uses a heuristic so it isn't + /// reliable for correctness. + virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const { + return 0; + } + /// hasLoadFromStackSlot - If the specified machine instruction has /// a load from a stack slot, return true along with the FrameIndex /// of the loaded stack slot. If not, return false. Unlike @@ -192,6 +200,14 @@ return 0; } + /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination + /// stack locations as well. This uses a heuristic so it isn't + /// reliable for correctness. + virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const { + return 0; + } + /// hasStoreToStackSlot - If the specified machine instruction has a /// store to a stack slot, return true along with the FrameIndex of /// the loaded stack slot. If not, return false. Unlike Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=87047&r1=87046&r2=87047&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Nov 12 18:29:53 2009 @@ -726,9 +726,8 @@ return false; } -unsigned X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, - int &FrameIndex) const { - switch (MI->getOpcode()) { +static bool isFrameLoadOpcode(int Opcode) { + switch (Opcode) { default: break; case X86::MOV8rm: case X86::MOV16rm: @@ -742,12 +741,49 @@ case X86::MOVDQArm: case X86::MMX_MOVD64rm: case X86::MMX_MOVQ64rm: - if (isFrameOperand(MI, 1, FrameIndex)) { + return true; + break; + } + return false; +} + +static bool isFrameStoreOpcode(int Opcode) { + switch (Opcode) { + default: break; + case X86::MOV8mr: + case X86::MOV16mr: + case X86::MOV32mr: + case X86::MOV64mr: + case X86::ST_FpP64m: + case X86::MOVSSmr: + case X86::MOVSDmr: + case X86::MOVAPSmr: + case X86::MOVAPDmr: + case X86::MOVDQAmr: + case X86::MMX_MOVD64mr: + case X86::MMX_MOVQ64mr: + case X86::MMX_MOVNTQmr: + return true; + } + return false; +} + +unsigned X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, + int &FrameIndex) const { + if (isFrameLoadOpcode(MI->getOpcode())) + if (isFrameOperand(MI, 1, FrameIndex)) return MI->getOperand(0).getReg(); - } + return 0; +} + +unsigned X86InstrInfo::isLoadFromStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const { + if (isFrameLoadOpcode(MI->getOpcode())) { + unsigned Reg; + if ((Reg = isLoadFromStackSlot(MI, FrameIndex))) + return Reg; // Check for post-frame index elimination operations return hasLoadFromStackSlot(MI, FrameIndex); - break; } return 0; } @@ -770,27 +806,20 @@ unsigned X86InstrInfo::isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case X86::MOV8mr: - case X86::MOV16mr: - case X86::MOV32mr: - case X86::MOV64mr: - case X86::ST_FpP64m: - case X86::MOVSSmr: - case X86::MOVSDmr: - case X86::MOVAPSmr: - case X86::MOVAPDmr: - case X86::MOVDQAmr: - case X86::MMX_MOVD64mr: - case X86::MMX_MOVQ64mr: - case X86::MMX_MOVNTQmr: - if (isFrameOperand(MI, 0, FrameIndex)) { + if (isFrameStoreOpcode(MI->getOpcode())) + if (isFrameOperand(MI, 0, FrameIndex)) return MI->getOperand(X86AddrNumOperands).getReg(); - } + return 0; +} + +unsigned X86InstrInfo::isStoreToStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const { + if (isFrameStoreOpcode(MI->getOpcode())) { + unsigned Reg; + if ((Reg = isStoreToStackSlot(MI, FrameIndex))) + return Reg; // Check for post-frame index elimination operations return hasStoreToStackSlot(MI, FrameIndex); - break; } return 0; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=87047&r1=87046&r2=87047&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Thu Nov 12 18:29:53 2009 @@ -449,6 +449,11 @@ unsigned &SrcSubIdx, unsigned &DstSubIdx) const; unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; + /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination + /// stack locations as well. This uses a heuristic so it isn't + /// reliable for correctness. + unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const; /// hasLoadFromStackSlot - If the specified machine instruction has /// a load from a stack slot, return true along with the FrameIndex @@ -459,6 +464,11 @@ bool hasLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; + /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination + /// stack locations as well. This uses a heuristic so it isn't + /// reliable for correctness. + unsigned isStoreToStackSlotPostFE(const MachineInstr *MI, + int &FrameIndex) const; /// hasStoreToStackSlot - If the specified machine instruction has a /// store to a stack slot, return true along with the FrameIndex of From wendling at apple.com Thu Nov 12 18:30:00 2009 From: wendling at apple.com (Bill Wendling) Date: Thu, 12 Nov 2009 16:30:00 -0800 Subject: [llvm-commits] [llvm] r87030 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp In-Reply-To: <6a8523d60911121626u1a43d64av5fe3de121890a091@mail.gmail.com> References: <200911122107.nACL7s2h009469@zion.cs.uiuc.edu> <6a8523d60911121626u1a43d64av5fe3de121890a091@mail.gmail.com> Message-ID: I'm in the process of doing a revert now. I'm just going to revert the patches that David committed during that time: for i in -87034 -87030 -87029 -87028 -87027 -87026 -87025 -87022 ; do echo $ svn merge -c $i https://llvm.org/svn/llvm-project/llvm/trunk svn merge -c $i https://llvm.org/svn/llvm-project/llvm/trunk done -bw On Nov 12, 2009, at 4:26 PM, Daniel Dunbar wrote: > Hi David, > > I think something in this commit sequence broke things, the buildbots > are failing everywhere. I'm going to revert-crazy as soon as I figure > out what to revert unless you beat me to it with a fix. :) > > - Daniel > > On Thu, Nov 12, 2009 at 1:07 PM, David Greene > wrote: >> Author: greened >> Date: Thu Nov 12 15:07:54 2009 >> New Revision: 87030 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=87030&view=rev >> Log: >> >> Set the ReloadReuse AsmPrinter flag where appropriate. >> >> Modified: >> llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp >> >> Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=87030&r1=87029&r2=87030&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) >> +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Nov 12 15:07:54 >> 2009 >> @@ -1704,6 +1704,7 @@ >> >> // Mark is killed. >> MachineInstr *CopyMI = prior(InsertLoc); >> + CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >> MachineOperand *KillOpnd = CopyMI- >> >findRegisterUseOperand(InReg); >> KillOpnd->setIsKill(); >> UpdateKills(*CopyMI, TRI, RegKills, KillOps); >> @@ -1984,6 +1985,7 @@ >> TII->copyRegToReg(MBB, InsertLoc, DesignatedReg, PhysReg, >> RC, RC); >> >> MachineInstr *CopyMI = prior(InsertLoc); >> + CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >> UpdateKills(*CopyMI, TRI, RegKills, KillOps); >> >> // This invalidates DesignatedReg. >> @@ -2112,6 +2114,7 @@ >> // virtual or needing to clobber any values if it's >> physical). >> NextMII = &MI; >> --NextMII; // backtrack to the copy. >> + NextMII->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >> // Propagate the sub-register index over. >> if (SubIdx) { >> DefMO = NextMII->findRegisterDefOperand(DestReg); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From wendling at apple.com Thu Nov 12 18:30:57 2009 From: wendling at apple.com (Bill Wendling) Date: Thu, 12 Nov 2009 16:30:57 -0800 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> Message-ID: <8CA100F5-8646-4AB4-B65A-D20C7087375E@apple.com> On Nov 12, 2009, at 4:29 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 18:29:53 2009 > New Revision: 87047 > > URL: http://llvm.org/viewvc/llvm-project?rev=87047&view=rev > Log: > > Fix a bootstrap failure. > > Provide special isLoadFromStackSlotPostFE and isStoreToStackSlotPostFE > interfaces to explicitly request checking for post-frame ptr > elimination > operands. This uses a heuristic so it isn't reliable for correctness. > What do you mean it isn't reliable for correctness?! How is this actually fixing anything then? -bw From dag at cray.com Thu Nov 12 18:34:04 2009 From: dag at cray.com (David Greene) Date: Thu, 12 Nov 2009 18:34:04 -0600 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <8CA100F5-8646-4AB4-B65A-D20C7087375E@apple.com> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> <8CA100F5-8646-4AB4-B65A-D20C7087375E@apple.com> Message-ID: <200911121834.04731.dag@cray.com> On Thursday 12 November 2009 18:30, Bill Wendling wrote: > On Nov 12, 2009, at 4:29 PM, David Greene wrote: > > Author: greened > > Date: Thu Nov 12 18:29:53 2009 > > New Revision: 87047 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=87047&view=rev > > Log: > > > > Fix a bootstrap failure. > > > > Provide special isLoadFromStackSlotPostFE and isStoreToStackSlotPostFE > > interfaces to explicitly request checking for post-frame ptr > > elimination > > operands. This uses a heuristic so it isn't reliable for correctness. > > What do you mean it isn't reliable for correctness?! How is this > actually fixing anything then? Because it's only being used for comments at the moment and those don't need to be 100% correct (though it would be nice). -Dave From echristo at apple.com Thu Nov 12 18:35:48 2009 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Nov 2009 16:35:48 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: <5A7C01CA-06E4-46EC-AA56-DBDFDBF92B5D@apple.com> References: <001636ed6e725660440478316be4@google.com> <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> <5A7C01CA-06E4-46EC-AA56-DBDFDBF92B5D@apple.com> Message-ID: <0BA4259E-11BE-4403-A351-68A4FA972F42@apple.com> On Nov 12, 2009, at 4:29 PM, Evan Cheng wrote: > > On Nov 12, 2009, at 2:35 PM, Jeffrey Yasskin wrote: > >> On Thu, Nov 12, 2009 at 11:46 AM, Dan Gohman wrote: >>> In the X86ISelLowering.cpp part, disabling the special handling >>> for GlobalAddresses and ExternalSymbols is fine, but the way the >>> proposed patch does that also happens to disable the >>> "else if (isTailCall)" code immediately below that, which handles >>> indirect tail calls. That code is still needed in the large code >>> model -- the callee needs to be in a specific physical register >>> so that it can survive the epilogue. >> >> Oh, right. New version of the patch at >> http://codereview.appspot.com/154066 / >> http://codereview.appspot.com/download/issue154066_23.diff >> >> On Thu, Nov 12, 2009 at 12:10 PM, Anton Korobeynikov >> wrote: >>> Also, the check for Is64Bit seems to be redundant - the codemodel >>> setting is valid only in 64 bit mode, thus "large code model" and >>> 32-bit code is undefined :) >> >> Oh! Ok. I don't see that actually enforced anywhere so I replaced the >> check with an assert instead of omitting it entirely. >> >> On Thu, Nov 12, 2009 at 12:58 PM, Evan Cheng wrote: >>> Looks good. The only comment apart from Dan and Anton's comments is to >>> force large code model for Darwin x86_64 as well unless explicitly >>> specified otherwise. >> >> That looks like an change in X86TargetMachine::addCodeEmitter()? Am I >> going to break anything if I leave that change to a separate commit? >> Since I don't have a Darwin x86_64 system, I'd rather have one of you >> guys make that change if possible. > > Yes. Eric should make that change. > I will. It "broke stuff" and I need to figure out what happened :) -eric From wendling at apple.com Thu Nov 12 18:37:02 2009 From: wendling at apple.com (Bill Wendling) Date: Thu, 12 Nov 2009 16:37:02 -0800 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <200911121834.04731.dag@cray.com> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> <8CA100F5-8646-4AB4-B65A-D20C7087375E@apple.com> <200911121834.04731.dag@cray.com> Message-ID: <282AD023-A5A2-449A-BF37-9068421C436B@apple.com> On Nov 12, 2009, at 4:34 PM, David Greene wrote: > On Thursday 12 November 2009 18:30, Bill Wendling wrote: >> On Nov 12, 2009, at 4:29 PM, David Greene wrote: >>> Author: greened >>> Date: Thu Nov 12 18:29:53 2009 >>> New Revision: 87047 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=87047&view=rev >>> Log: >>> >>> Fix a bootstrap failure. >>> >>> Provide special isLoadFromStackSlotPostFE and >>> isStoreToStackSlotPostFE >>> interfaces to explicitly request checking for post-frame ptr >>> elimination >>> operands. This uses a heuristic so it isn't reliable for >>> correctness. >> >> What do you mean it isn't reliable for correctness?! How is this >> actually fixing anything then? > > Because it's only being used for comments at the moment and those > don't > need to be 100% correct (though it would be nice). > This makes no sense to me. What do you mean "comments"? What comments? I'm not happy with the state of affairs. The build bots have been broken all day. Unless you can say that this patch fixes the *real* problem with the bootstrap, and not some "comment" that isn't "reliable" for correctness, then I'll be reverting all of your work today. -bw From dag at cray.com Thu Nov 12 18:40:59 2009 From: dag at cray.com (David Greene) Date: Thu, 12 Nov 2009 18:40:59 -0600 Subject: [llvm-commits] =?iso-8859-1?q?=5Bllvm=5D_r87047_-_in_/llvm/trunk?= =?iso-8859-1?q?=3A_include/llvm/Target/TargetInstrInfo=2Eh=09lib/Target/X?= =?iso-8859-1?q?86/X86InstrInfo=2Ecpp_lib/Target/X86/X86InstrInfo=2Eh?= In-Reply-To: <282AD023-A5A2-449A-BF37-9068421C436B@apple.com> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> <200911121834.04731.dag@cray.com> <282AD023-A5A2-449A-BF37-9068421C436B@apple.com> Message-ID: <200911121840.59910.dag@cray.com> On Thursday 12 November 2009 18:37, Bill Wendling wrote: > > Because it's only being used for comments at the moment and those > > don't > > need to be 100% correct (though it would be nice). > > This makes no sense to me. What do you mean "comments"? What comments? Asm comments. The last bit still needs to be checked in (tomorrow). > I'm not happy with the state of affairs. The build bots have been > broken all day. Unless you can say that this patch fixes the *real* That can't be just from me. I only started checking in at 3pm. > problem with the bootstrap, and not some "comment" that isn't > "reliable" for correctness, then I'll be reverting all of your work > today. Yes, it fixes the "real" problem AFAICT. Your testcase compiles. I can't see any other Darwin failures since I don't have access to a Darwin box. -Dave From dalej at apple.com Thu Nov 12 18:44:48 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 12 Nov 2009 16:44:48 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> Message-ID: <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> On Nov 11, 2009, at 3:05 PMPST, Bob Wilson wrote: > Author: bwilson > Date: Wed Nov 11 17:05:45 2009 > New Revision: 86892 > > URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev > Log: > Fix pr5406: When passing an aggregate in integer registers, the data > cannot > be split up into integer types smaller than the target registers. > Most of > the data is put into an array of i32 or i64 values, and that part is > OK. But, > if the size is not a multiple of 32 or 64, there may be some > leftover bytes > to be passed separately. Change to pass those leftover bytes in a > single > integer. The x86_64 target already does this in target-specific code. > This also fixes radars 7226380 and 7226213. This patch broke binary compatibility on Darwin PPC, as shown by running gcc's struct-layout-1 tests to compare against the installed compiler. (The last 2 bytes of a 6-byte struct (for example) are passed left justified within a word on that target.) From wendling at apple.com Thu Nov 12 18:45:04 2009 From: wendling at apple.com (Bill Wendling) Date: Thu, 12 Nov 2009 16:45:04 -0800 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <200911121840.59910.dag@cray.com> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> <200911121834.04731.dag@cray.com> <282AD023-A5A2-449A-BF37-9068421C436B@apple.com> <200911121840.59910.dag@cray.com> Message-ID: <0DFBD55D-E085-4AB3-828C-7DF87D84BC0C@apple.com> On Nov 12, 2009, at 4:40 PM, David Greene wrote: > On Thursday 12 November 2009 18:37, Bill Wendling wrote: > >>> Because it's only being used for comments at the moment and those >>> don't >>> need to be 100% correct (though it would be nice). >> >> This makes no sense to me. What do you mean "comments"? What >> comments? > > Asm comments. The last bit still needs to be checked in (tomorrow). > >> I'm not happy with the state of affairs. The build bots have been >> broken all day. Unless you can say that this patch fixes the *real* > > That can't be just from me. I only started checking in at 3pm. > I sent a list around of the failures from when it started failing. They were all from you. I'm not trying to embarrass you, but that's what I saw. >> problem with the bootstrap, and not some "comment" that isn't >> "reliable" for correctness, then I'll be reverting all of your work >> today. > > Yes, it fixes the "real" problem AFAICT. Your testcase compiles. I > can't > see any other Darwin failures since I don't have access to a Darwin > box. > Thank you. Please be more informative in your commit messages when you're fixing build failures. The message sounded like you were slapping a heuristic down to fix a bootstrap failure that wasn't reliable for correctness. Such a situation is obviously not acceptable. *Rage subsiding* -bw From evan.cheng at apple.com Thu Nov 12 18:57:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 16:57:24 -0800 Subject: [llvm-commits] [llvm] r87026 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <200911122055.nACKtTGj008965@zion.cs.uiuc.edu> References: <200911122055.nACKtTGj008965@zion.cs.uiuc.edu> Message-ID: <2A9B4966-EE45-422A-9DB4-CC41D0DB2619@apple.com> Why can't you just rely on memoperands? Evan On Nov 12, 2009, at 12:55 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 14:55:29 2009 > New Revision: 87026 > > URL: http://llvm.org/viewvc/llvm-project?rev=87026&view=rev > Log: > > Add hasLoadFromStackSlot and hasStoreToStackSlot to return whether a > machine instruction loads or stores from/to a stack slot. Unlike > isLoadFromStackSlot and isStoreFromStackSlot, the instruction may be > something other than a pure load/store (e.g. it may be an arithmetic > operation with a memory operand). This helps AsmPrinter determine > when > to print a spill/reload comment. > > This is only a hint since we may not be able to figure this out in all > cases. As such, it should not be relied upon for correctness. > > Implement for X86. Return false by default for other architectures. > > Modified: > llvm/trunk/include/llvm/Target/TargetInstrInfo.h > llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > llvm/trunk/lib/Target/X86/X86InstrInfo.h > > Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=87026&r1=87025&r2=87026&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) > +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Thu Nov 12 > 14:55:29 2009 > @@ -170,6 +170,17 @@ > int &FrameIndex) const { > return 0; > } > + > + /// hasLoadFromStackSlot - If the specified machine instruction has > + /// a load from a stack slot, return true along with the FrameIndex > + /// of the loaded stack slot. If not, return false. Unlike > + /// isLoadFromStackSlot, this returns true for any instructions > that > + /// loads from the stack. This is just a hint, as some cases may > be > + /// missed. > + virtual bool hasLoadFromStackSlot(const MachineInstr *MI, > + int &FrameIndex) const { > + return 0; > + } > > /// isStoreToStackSlot - If the specified machine instruction is a > direct > /// store to a stack slot, return the virtual or physical register > number of > @@ -181,6 +192,17 @@ > return 0; > } > > + /// hasStoreToStackSlot - If the specified machine instruction > has a > + /// store to a stack slot, return true along with the FrameIndex of > + /// the loaded stack slot. If not, return false. Unlike > + /// isStoreToStackSlot, this returns true for any instructions that > + /// loads from the stack. This is just a hint, as some cases may > be > + /// missed. > + virtual bool hasStoreToStackSlot(const MachineInstr *MI, > + int &FrameIndex) const { > + return 0; > + } > + > /// reMaterialize - Re-issue the specified 'original' instruction at > the > /// specific location targeting a new destination register. > virtual void reMaterialize(MachineBasicBlock &MBB, > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=87026&r1=87025&r2=87026&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Nov 12 14:55:29 > 2009 > @@ -26,11 +26,15 @@ > #include "llvm/CodeGen/MachineInstrBuilder.h" > #include "llvm/CodeGen/MachineRegisterInfo.h" > #include "llvm/CodeGen/LiveVariables.h" > +#include "llvm/CodeGen/PseudoSourceValue.h" > #include "llvm/Support/CommandLine.h" > #include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/raw_ostream.h" > #include "llvm/Target/TargetOptions.h" > #include "llvm/MC/MCAsmInfo.h" > + > +#include > + > using namespace llvm; > > static cl::opt > @@ -707,6 +711,21 @@ > } > } > > +/// isFrameOperand - Return true and the FrameIndex if the specified > +/// operand and follow operands form a reference to the stack frame. > +bool X86InstrInfo::isFrameOperand(const MachineInstr *MI, unsigned > int Op, > + int &FrameIndex) const { > + if (MI->getOperand(Op).isFI() && MI->getOperand(Op+1).isImm() && > + MI->getOperand(Op+2).isReg() && MI->getOperand(Op+3).isImm() && > + MI->getOperand(Op+1).getImm() == 1 && > + MI->getOperand(Op+2).getReg() == 0 && > + MI->getOperand(Op+3).getImm() == 0) { > + FrameIndex = MI->getOperand(Op).getIndex(); > + return true; > + } > + return false; > +} > + > unsigned X86InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, > int &FrameIndex) const { > switch (MI->getOpcode()) { > @@ -723,19 +742,32 @@ > case X86::MOVDQArm: > case X86::MMX_MOVD64rm: > case X86::MMX_MOVQ64rm: > - if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && > - MI->getOperand(3).isReg() && MI->getOperand(4).isImm() && > - MI->getOperand(2).getImm() == 1 && > - MI->getOperand(3).getReg() == 0 && > - MI->getOperand(4).getImm() == 0) { > - FrameIndex = MI->getOperand(1).getIndex(); > + if (isFrameOperand(MI, 1, FrameIndex)) { > return MI->getOperand(0).getReg(); > } > + // Check for post-frame index elimination operations > + return hasLoadFromStackSlot(MI, FrameIndex); > break; > } > return 0; > } > > +bool X86InstrInfo::hasLoadFromStackSlot(const MachineInstr *MI, > + int &FrameIndex) const { > + for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), > + oe = MI->memoperands_end(); > + o != oe; > + ++o) { > + if ((*o)->isLoad() && (*o)->getValue()) > + if (const FixedStackPseudoSourceValue *Value = > + dyn_cast((*o)->getValue > ())) { > + FrameIndex = Value->getFrameIndex(); > + return true; > + } > + } > + return false; > +} > + > unsigned X86InstrInfo::isStoreToStackSlot(const MachineInstr *MI, > int &FrameIndex) const { > switch (MI->getOpcode()) { > @@ -753,19 +785,32 @@ > case X86::MMX_MOVD64mr: > case X86::MMX_MOVQ64mr: > case X86::MMX_MOVNTQmr: > - if (MI->getOperand(0).isFI() && MI->getOperand(1).isImm() && > - MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && > - MI->getOperand(1).getImm() == 1 && > - MI->getOperand(2).getReg() == 0 && > - MI->getOperand(3).getImm() == 0) { > - FrameIndex = MI->getOperand(0).getIndex(); > + if (isFrameOperand(MI, 0, FrameIndex)) { > return MI->getOperand(X86AddrNumOperands).getReg(); > } > + // Check for post-frame index elimination operations > + return hasStoreToStackSlot(MI, FrameIndex); > break; > } > return 0; > } > > +bool X86InstrInfo::hasStoreToStackSlot(const MachineInstr *MI, > + int &FrameIndex) const { > + for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), > + oe = MI->memoperands_end(); > + o != oe; > + ++o) { > + if ((*o)->isStore() && (*o)->getValue()) > + if (const FixedStackPseudoSourceValue *Value = > + dyn_cast((*o)->getValue > ())) { > + FrameIndex = Value->getFrameIndex(); > + return true; > + } > + } > + return false; > +} > + > /// regIsPICBase - Return true if register is PIC base (i.e.g > defined by > /// X86::MOVPC32r. > static bool regIsPICBase(unsigned BaseReg, const MachineRegisterInfo > &MRI) { > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=87026&r1=87025&r2=87026&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Thu Nov 12 14:55:29 2009 > @@ -449,8 +449,25 @@ > unsigned &SrcSubIdx, unsigned &DstSubIdx) > const; > > unsigned isLoadFromStackSlot(const MachineInstr *MI, int > &FrameIndex) const; > + > + /// hasLoadFromStackSlot - If the specified machine instruction has > + /// a load from a stack slot, return true along with the FrameIndex > + /// of the loaded stack slot. If not, return false. Unlike > + /// isLoadFromStackSlot, this returns true for any instructions > that > + /// loads from the stack. This is a hint only and may not catch > all > + /// cases. > + bool hasLoadFromStackSlot(const MachineInstr *MI, int > &FrameIndex) const; > + > unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) > const; > > + /// hasStoreToStackSlot - If the specified machine instruction > has a > + /// store to a stack slot, return true along with the FrameIndex of > + /// the loaded stack slot. If not, return false. Unlike > + /// isStoreToStackSlot, this returns true for any instructions that > + /// loads from the stack. This is a hint only and may not catch > all > + /// cases. > + bool hasStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) > const; > + > bool isReallyTriviallyReMaterializable(const MachineInstr *MI, > AliasAnalysis *AA) const; > void reMaterialize(MachineBasicBlock &MBB, > MachineBasicBlock::iterator MI, > @@ -610,6 +627,11 @@ > unsigned OpNum, > const > SmallVectorImpl &MOs, > unsigned Size, unsigned > Alignment) const; > + > + /// isFrameOperand - Return true and the FrameIndex if the > specified > + /// operand and follow operands form a reference to the stack > frame. > + bool isFrameOperand(const MachineInstr *MI, unsigned int Op, > + int &FrameIndex) const; > }; > > } // End llvm namespace > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Thu Nov 12 19:00:54 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Nov 2009 17:00:54 -0800 Subject: [llvm-commits] [llvm] r87022 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ In-Reply-To: <200911122049.nACKnPDw008707@zion.cs.uiuc.edu> References: <200911122049.nACKnPDw008707@zion.cs.uiuc.edu> Message-ID: Why is this necessary? As of 84326 each StackObject already has a isSpillSlot bool field. Evan On Nov 12, 2009, at 12:49 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 14:49:22 2009 > New Revision: 87022 > > URL: http://llvm.org/viewvc/llvm-project?rev=87022&view=rev > Log: > > Add a bool flag to StackObjects telling whether they reference spill > slots. The AsmPrinter will use this information to determine > whether to > print a spill/reload comment. > > Remove default argument values. It's too easy to pass a wrong > argument > value when multiple arguments have default values. Make everything > explicit to trap bugs early. > > Update all targets to adhere to the new interfaces.. > > Modified: > llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h > llvm/trunk/lib/CodeGen/MachineFunction.cpp > llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp > llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp > llvm/trunk/lib/CodeGen/RegAllocLocal.cpp > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp > llvm/trunk/lib/CodeGen/VirtRegMap.cpp > llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp > llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp > llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp > llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp > llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp > llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp > llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp > llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp > llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp > llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp > llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp > llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp > llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp > llvm/trunk/lib/Target/X86/X86FastISel.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp > llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Thu Nov 12 > 14:49:22 2009 > @@ -15,9 +15,11 @@ > #define LLVM_CODEGEN_MACHINEFRAMEINFO_H > > #include "llvm/ADT/BitVector.h" > -#include "llvm/ADT/DenseSet.h" > +#include "llvm/ADT/DenseMap.h" > +#include "llvm/ADT/SmallVector.h" > #include "llvm/System/DataTypes.h" > #include > +#include > #include > > namespace llvm { > @@ -106,8 +108,8 @@ > // cannot alias any other memory objects. > bool isSpillSlot; > > - StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = > false, > - bool isSS = false) > + StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, > + bool isSS) > : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), > isSpillSlot(isSS) {} > }; > @@ -182,6 +184,10 @@ > /// CSIValid - Has CSInfo been set yet? > bool CSIValid; > > + /// SpillObjects - A vector indicating which frame indices refer to > + /// spill slots. > + SmallVector SpillObjects; > + > /// MMI - This field is set (via setMachineModuleInfo) by a module > info > /// consumer (ex. DwarfWriter) to indicate that frame layout > information > /// should be acquired. Typically, it's the responsibility of the > target's > @@ -192,6 +198,7 @@ > /// TargetFrameInfo - Target information about frame layout. > /// > const TargetFrameInfo &TFI; > + > public: > explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { > StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; > @@ -341,7 +348,7 @@ > /// index with a negative value. > /// > int CreateFixedObject(uint64_t Size, int64_t SPOffset, > - bool Immutable = true); > + bool Immutable, bool isSS); > > > /// isFixedObjectIndex - Returns true if the specified index > corresponds to a > @@ -374,13 +381,31 @@ > return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; > } > > - /// CreateStackObject - Create a new statically sized stack > object, returning > - /// a nonnegative identifier to represent it. > + /// CreateStackObject - Create a new statically sized stack object, > + /// returning a nonnegative identifier to represent it. > /// > - int CreateStackObject(uint64_t Size, unsigned Alignment, bool > isSS = false) { > + int CreateStackObject(uint64_t Size, unsigned Alignment, bool > isSS) { > assert(Size != 0 && "Cannot allocate zero size stack objects!"); > Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); > - return (int)Objects.size()-NumFixedObjects-1; > + int Index = (int)Objects.size()-NumFixedObjects-1; > + assert(Index >= 0 && "Bad frame index!"); > + if (SpillObjects.size() <= static_cast(Index)) > + SpillObjects.resize(Index+1); > + SpillObjects[Index] = false; > + return Index; > + } > + > + /// CreateSpillStackObject - Create a new statically sized stack > + /// object that represents a spill slot, returning a nonnegative > + /// identifier to represent it. > + /// > + int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { > + CreateStackObject(Size, Alignment, true); > + int Index = (int)Objects.size()-NumFixedObjects-1; > + if (SpillObjects.size() <= static_cast(Index)) > + SpillObjects.resize(Index+1); > + SpillObjects[Index] = true; > + return Index; > } > > /// RemoveStackObject - Remove or mark dead a statically sized > stack object. > @@ -397,10 +422,20 @@ > /// > int CreateVariableSizedObject() { > HasVarSizedObjects = true; > - Objects.push_back(StackObject(0, 1)); > + Objects.push_back(StackObject(0, 1, 0, false, false)); > return (int)Objects.size()-NumFixedObjects-1; > } > - > + > + /// isSpillObject - Return whether the index refers to a spill > slot. > + /// > + bool isSpillObject(int Index) const { > + // Negative indices can't be spill slots. > + if (Index < 0) return false; > + assert(static_cast(Index) < SpillObjects.size() && > + "Invalid frame index!"); > + return SpillObjects[Index]; > + } > + > /// getCalleeSavedInfo - Returns a reference to call saved info > vector for the > /// current function. > const std::vector &getCalleeSavedInfo() const { > > Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Thu Nov 12 14:49:22 > 2009 > @@ -441,9 +441,10 @@ > /// index with a negative value. > /// > int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t > SPOffset, > - bool Immutable) { > + bool Immutable, bool isSS) { > assert(Size != 0 && "Cannot allocate zero size fixed stack > objects!"); > - Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, > Immutable)); > + Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, > Immutable, > + isSS)); > return -++NumFixedObjects; > } > > > Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) > +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Thu Nov 12 14:49:22 > 2009 > @@ -341,7 +341,7 @@ > if (I != IntervalSSMap.end()) { > SS = I->second; > } else { > - SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); > + SS = MFI->CreateSpillStackObject(RC->getSize(), RC->getAlignment > ()); > IntervalSSMap[Reg] = SS; > } > > @@ -957,7 +957,7 @@ > if (I != IntervalSSMap.end()) { > SS = I->second; > } else { > - SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); > + SS = MFI->CreateSpillStackObject(RC->getSize(), RC->getAlignment > ()); > } > > MachineInstr* FMI = TII->foldMemoryOperand(*MBB->getParent(), > > Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) > +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Thu Nov 12 > 14:49:22 2009 > @@ -264,7 +264,8 @@ > if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = > FrameIdx; > } else { > // Spill it to the stack where we must. > - FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot- > >Offset); > + FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot- > >Offset, > + true, false); > } > > I->setFrameIdx(FrameIdx); > > Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) > +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Thu Nov 12 14:49:22 2009 > @@ -261,8 +261,8 @@ > return SS; // Already has space allocated? > > // Allocate a new stack object for this spill location... > - int FrameIdx = MF->getFrameInfo()->CreateStackObject(RC->getSize(), > - RC- > >getAlignment(),true); > + int FrameIdx = MF->getFrameInfo()->CreateSpillStackObject(RC- > >getSize(), > + RC- > >getAlignment()); > > // Assign the slot... > StackSlotForVirtReg[VirtReg] = FrameIdx; > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1379,7 +1379,7 @@ > unsigned StackAlign = > std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), > minAlign); > > - int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign); > + int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign, > false); > return getFrameIndex(FrameIdx, TLI.getPointerTy()); > } > > @@ -1395,7 +1395,7 @@ > TD->getPrefTypeAlignment(Ty2)); > > MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo(); > - int FrameIdx = FrameInfo->CreateStackObject(Bytes, Align); > + int FrameIdx = FrameInfo->CreateStackObject(Bytes, Align, false); > return getFrameIndex(FrameIdx, TLI.getPointerTy()); > } > > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp > (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Thu > Nov 12 14:49:22 2009 > @@ -305,7 +305,7 @@ > TySize *= CUI->getZExtValue(); // Get total allocated size. > if (TySize == 0) TySize = 1; // Don't create zero-sized > stack objects. > StaticAllocaMap[AI] = > - MF->getFrameInfo()->CreateStackObject(TySize, Align); > + MF->getFrameInfo()->CreateStackObject(TySize, Align, > false); > } > > for (; BB != EB; ++BB) > @@ -4439,7 +4439,7 @@ > unsigned Align = TLI.getTargetData()->getPrefTypeAlignment( > FTy->getReturnType()); > MachineFunction &MF = DAG.getMachineFunction(); > - int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align); > + int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align, > false); > const Type *StackSlotPtrType = PointerType::getUnqual(FTy- > >getReturnType()); > > DemoteStackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); > @@ -5276,7 +5276,7 @@ > uint64_t TySize = TLI.getTargetData()->getTypeAllocSize(Ty); > unsigned Align = TLI.getTargetData()->getPrefTypeAlignment > (Ty); > MachineFunction &MF = DAG.getMachineFunction(); > - int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, > Align); > + int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, > Align, false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy > ()); > Chain = DAG.getStore(Chain, getCurDebugLoc(), > OpInfo.CallOperand, StackSlot, NULL, 0); > > Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) > +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Thu Nov 12 14:49:22 2009 > @@ -117,8 +117,8 @@ > assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT && > "attempt to assign stack slot to already spilled register"); > const TargetRegisterClass* RC = MF->getRegInfo().getRegClass > (virtReg); > - int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), > - RC->getAlignment(), / > *isSS*/true); > + int SS = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), > + RC->getAlignment()); > if (LowSpillSlot == NO_STACK_SLOT) > LowSpillSlot = SS; > if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) > @@ -161,8 +161,8 @@ > EmergencySpillSlots.find(RC); > if (I != EmergencySpillSlots.end()) > return I->second; > - int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), > - RC->getAlignment(), / > *isSS*/true); > + int SS = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), > + RC->getAlignment()); > if (LowSpillSlot == NO_STACK_SLOT) > LowSpillSlot = SS; > if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) > > Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -774,7 +774,8 @@ > // Reserve a slot closest to SP or frame pointer. > const TargetRegisterClass *RC = ARM::GPRRegisterClass; > RS->setScavengingFrameIndex(MFI->CreateStackObject(RC- > >getSize(), > - RC- > >getAlignment())); > + RC- > >getAlignment(), > + false)); > } > } > } > @@ -791,7 +792,8 @@ > return ARM::LR; > } > > -unsigned ARMBaseRegisterInfo::getFrameRegister(MachineFunction &MF) > const { > +unsigned > +ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) > const { > if (STI.isTargetDarwin() || hasFP(MF)) > return FramePtr; > return ARM::SP; > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1545,7 +1545,8 @@ > if (NextVA.isMemLoc()) { > unsigned ArgSize = NextVA.getLocVT().getSizeInBits()/8; > MachineFrameInfo *MFI = MF.getFrameInfo(); > - int FI = MFI->CreateFixedObject(ArgSize, NextVA.getLocMemOffset > ()); > + int FI = MFI->CreateFixedObject(ArgSize, NextVA.getLocMemOffset > (), > + true, false); > > // Create load node to retrieve arguments from the stack. > SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); > @@ -1659,7 +1660,8 @@ > assert(VA.getValVT() != MVT::i64 && "i64 should already be > lowered"); > > unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; > - int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset()); > + int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset(), > + true, false); > > // Create load nodes to retrieve arguments from the stack. > SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); > @@ -1687,7 +1689,8 @@ > // the result of va_next. > AFI->setVarArgsRegSaveSize(VARegSaveSize); > VarArgsFrameIndex = MFI->CreateFixedObject(VARegSaveSize, > ArgOffset + > - VARegSaveSize - > VARegSize); > + VARegSaveSize - > VARegSize, > + true, false); > SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, getPointerTy > ()); > > SmallVector MemOps; > @@ -1711,7 +1714,7 @@ > &MemOps[0], MemOps.size()); > } else > // This will point to the next argument passed via stack. > - VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset); > + VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset, > true, false); > } > > return Chain; > > Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -426,7 +426,7 @@ > } > } else { //more args > // Create the frame index object for this incoming parameter... > - int FI = MFI->CreateFixedObject(8, 8 * (ArgNo - 6)); > + int FI = MFI->CreateFixedObject(8, 8 * (ArgNo - 6), true, > false); > > // Create the SelectionDAG nodes corresponding to a load > //from this parameter > @@ -444,7 +444,7 @@ > if (TargetRegisterInfo::isPhysicalRegister(args_int[i])) > args_int[i] = AddLiveIn(MF, args_int[i], > &Alpha::GPRCRegClass); > SDValue argt = DAG.getCopyFromReg(Chain, dl, args_int[i], > MVT::i64); > - int FI = MFI->CreateFixedObject(8, -8 * (6 - i)); > + int FI = MFI->CreateFixedObject(8, -8 * (6 - i), true, false); > if (i == 0) VarArgsBase = FI; > SDValue SDFI = DAG.getFrameIndex(FI, MVT::i64); > LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); > @@ -452,7 +452,7 @@ > if (TargetRegisterInfo::isPhysicalRegister(args_float[i])) > args_float[i] = AddLiveIn(MF, args_float[i], > &Alpha::F8RCRegClass); > argt = DAG.getCopyFromReg(Chain, dl, args_float[i], MVT::f64); > - FI = MFI->CreateFixedObject(8, - 8 * (12 - i)); > + FI = MFI->CreateFixedObject(8, - 8 * (12 - i), true, false); > SDFI = DAG.getFrameIndex(FI, MVT::i64); > LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); > } > > Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Thu Nov > 12 14:49:22 2009 > @@ -207,7 +207,8 @@ > } else { > assert(VA.isMemLoc() && "CCValAssign must be RegLoc or MemLoc"); > unsigned ObjSize = VA.getLocVT().getStoreSize(); > - int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset()); > + int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset(), > + true, false); > SDValue FIN = DAG.getFrameIndex(FI, MVT::i32); > InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, > NULL, 0)); > } > > Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Thu Nov > 12 14:49:22 2009 > @@ -368,7 +368,8 @@ > if (requiresRegisterScavenging(MF)) { > // Reserve a slot close to SP or frame pointer. > RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), > - RC- > >getAlignment())); > + RC- > >getAlignment(), > + false)); > } > } > > @@ -449,7 +450,8 @@ > return BF::RETS; > } > > -unsigned BlackfinRegisterInfo::getFrameRegister(MachineFunction > &MF) const { > +unsigned > +BlackfinRegisterInfo::getFrameRegister(const MachineFunction &MF) > const { > return hasFP(MF) ? BF::FP : BF::SP; > } > > > Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1090,7 +1090,7 @@ > // We need to load the argument to a virtual register if we > determined > // above that we ran out of physical registers of the > appropriate type > // or we're forced to do vararg > - int FI = MFI->CreateFixedObject(ObjSize, ArgOffset); > + int FI = MFI->CreateFixedObject(ObjSize, ArgOffset, true, > false); > SDValue FIN = DAG.getFrameIndex(FI, PtrVT); > ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); > ArgOffset += StackSlotSize; > @@ -1110,7 +1110,8 @@ > // Create the frame slot > > for (; ArgRegIdx != NumArgRegs; ++ArgRegIdx) { > - VarArgsFrameIndex = MFI->CreateFixedObject(StackSlotSize, > ArgOffset); > + VarArgsFrameIndex = MFI->CreateFixedObject(StackSlotSize, > ArgOffset, > + true, false); > SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); > SDValue ArgVal = DAG.getRegister(ArgRegs[ArgRegIdx], > MVT::v16i8); > SDValue Store = DAG.getStore(Chain, dl, ArgVal, FIN, NULL, 0); > > Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -318,7 +318,7 @@ > << "\n"; > } > // Create the frame index object for this incoming parameter... > - int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset()); > + int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset > (), true, false); > > // Create the SelectionDAG nodes corresponding to a load > //from this parameter > > Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -212,7 +212,7 @@ > const > { > // Create a frame entry for the FPW register that must be saved. > if (hasFP(MF)) { > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(2, -4); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(2, -4, > true, false); > assert(FrameIdx == MF.getFrameInfo()->getObjectIndexBegin() && > "Slot for FPW register must be last in order to be > found!"); > FrameIdx = 0; > @@ -355,7 +355,7 @@ > return MSP430::PCW; > } > > -unsigned MSP430RegisterInfo::getFrameRegister(MachineFunction &MF) > const { > +unsigned MSP430RegisterInfo::getFrameRegister(const MachineFunction > &MF) const { > return hasFP(MF) ? MSP430::FPW : MSP430::SPW; > } > > > Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -704,7 +704,7 @@ > // the stack (even if less than 4 are used as arguments) > if (Subtarget->isABI_O32()) { > int VTsize = EVT(MVT::i32).getSizeInBits()/8; > - MFI->CreateFixedObject(VTsize, (VTsize*3)); > + MFI->CreateFixedObject(VTsize, (VTsize*3), true, false); > CCInfo.AnalyzeCallOperands(Outs, CC_MipsO32); > } else > CCInfo.AnalyzeCallOperands(Outs, CC_Mips); > @@ -773,7 +773,7 @@ > // if O32 ABI is used. For EABI the first address is zero. > LastArgStackLoc = (FirstStackArgLoc + VA.getLocMemOffset()); > int FI = MFI->CreateFixedObject(VA.getValVT().getSizeInBits()/8, > - LastArgStackLoc); > + LastArgStackLoc, true, false); > > SDValue PtrOff = DAG.getFrameIndex(FI,getPointerTy()); > > @@ -849,7 +849,7 @@ > // Create the frame index only once. SPOffset here can be > anything > // (this will be fixed on processFunctionBeforeFrameFinalized) > if (MipsFI->getGPStackOffset() == -1) { > - FI = MFI->CreateFixedObject(4, 0); > + FI = MFI->CreateFixedObject(4, 0, true, false); > MipsFI->setGPFI(FI); > } > MipsFI->setGPStackOffset(LastArgStackLoc); > @@ -1002,7 +1002,7 @@ > // be used on emitPrologue) to avoid mis-calc of the first > stack > // offset on PEI::calculateFrameObjectOffsets. > // Arguments are always 32-bit. > - int FI = MFI->CreateFixedObject(4, 0); > + int FI = MFI->CreateFixedObject(4, 0, true, false); > MipsFI->recordStoreVarArgsFI(FI, -(4+(i*4))); > SDValue PtrOff = DAG.getFrameIndex(FI, getPointerTy()); > > @@ -1025,7 +1025,7 @@ > // offset on PEI::calculateFrameObjectOffsets. > // Arguments are always 32-bit. > unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; > - int FI = MFI->CreateFixedObject(ArgSize, 0); > + int FI = MFI->CreateFixedObject(ArgSize, 0, true, false); > MipsFI->recordLoadArgsFI(FI, -(ArgSize+ > (FirstStackArgLoc + VA.getLocMemOffset()))); > > > Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -287,7 +287,7 @@ > } > > if (hasFP(MF)) { > - MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize), > + MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize, > true), > StackOffset); > MipsFI->setFPStackOffset(StackOffset); > TopCPUSavedRegOff = StackOffset; > @@ -295,7 +295,7 @@ > } > > if (MFI->hasCalls()) { > - MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize), > + MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize, > true), > StackOffset); > MipsFI->setRAStackOffset(StackOffset); > TopCPUSavedRegOff = StackOffset; > @@ -501,7 +501,7 @@ > } > > unsigned MipsRegisterInfo:: > -getFrameRegister(MachineFunction &MF) const { > +getFrameRegister(const MachineFunction &MF) const { > return hasFP(MF) ? Mips::FP : Mips::SP; > } > > > Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1070,7 +1070,7 @@ > > // Put the value on stack. > // Get a stack slot index and convert to es. > - int FI = MF.getFrameInfo()->CreateStackObject(1, 1); > + int FI = MF.getFrameInfo()->CreateStackObject(1, 1, false); > const char *tmpName = createESName(PAN::getTempdataLabel(FuncName)); > SDValue ES = DAG.getTargetExternalSymbol(tmpName, MVT::i8); > > > Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1625,7 +1625,7 @@ > > unsigned ArgSize = VA.getLocVT().getSizeInBits() / 8; > int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset(), > - isImmutable); > + isImmutable, false); > > // Create load nodes to retrieve arguments from the stack. > SDValue FIN = DAG.getFrameIndex(FI, PtrVT); > @@ -1690,9 +1690,10 @@ > NumFPArgRegs * EVT(MVT::f64).getSizeInBits()/8; > > VarArgsStackOffset = MFI->CreateFixedObject(PtrVT.getSizeInBits > ()/8, > - > CCInfo.getNextStackOffset()); > + > CCInfo.getNextStackOffset(), > + true, false); > > - VarArgsFrameIndex = MFI->CreateStackObject(Depth, 8); > + VarArgsFrameIndex = MFI->CreateStackObject(Depth, 8, false); > SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); > > // The fixed integer arguments of a variadic function are > @@ -1895,7 +1896,7 @@ > CurArgOffset = CurArgOffset + (4 - ObjSize); > } > // The value of the object is its address. > - int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset); > + int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset, true, > false); > SDValue FIN = DAG.getFrameIndex(FI, PtrVT); > InVals.push_back(FIN); > if (ObjSize==1 || ObjSize==2) { > @@ -1918,7 +1919,7 @@ > // the object. > if (GPR_idx != Num_GPR_Regs) { > unsigned VReg = MF.addLiveIn(GPR[GPR_idx], > &PPC::GPRCRegClass); > - int FI = MFI->CreateFixedObject(PtrByteSize, ArgOffset); > + int FI = MFI->CreateFixedObject(PtrByteSize, ArgOffset, > true, false); > SDValue FIN = DAG.getFrameIndex(FI, PtrVT); > SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); > SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, > FIN, NULL, 0); > @@ -2043,7 +2044,7 @@ > if (needsLoad) { > int FI = MFI->CreateFixedObject(ObjSize, > CurArgOffset + (ArgSize - > ObjSize), > - isImmutable); > + isImmutable, false); > SDValue FIN = DAG.getFrameIndex(FI, PtrVT); > ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); > } > @@ -2076,7 +2077,7 @@ > int Depth = ArgOffset; > > VarArgsFrameIndex = MFI->CreateFixedObject(PtrVT.getSizeInBits()/ > 8, > - Depth); > + Depth, true, false); > SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); > > // If this function is vararg, store any remaining integer > argument regs > @@ -2289,7 +2290,8 @@ > int NewRetAddrLoc = SPDiff + PPCFrameInfo::getReturnSaveOffset > (isPPC64, > > isDarwinABI); > int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize, > - > NewRetAddrLoc); > + > NewRetAddrLoc, > + true, > false); > EVT VT = isPPC64 ? MVT::i64 : MVT::i32; > SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); > Chain = DAG.getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx, > @@ -2300,7 +2302,8 @@ > if (isDarwinABI) { > int NewFPLoc = > SPDiff + PPCFrameInfo::getFramePointerSaveOffset(isPPC64, > isDarwinABI); > - int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, > NewFPLoc); > + int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, > NewFPLoc, > + true, > false); > SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); > Chain = DAG.getStore(Chain, dl, OldFP, NewFramePtrIdx, > PseudoSourceValue::getFixedStack > (NewFPIdx), 0); > @@ -2317,7 +2320,7 @@ > SmallVector& > TailCallArguments) { > int Offset = ArgOffset + SPDiff; > uint32_t OpSize = (Arg.getValueType().getSizeInBits()+7)/8; > - int FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); > + int FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset, > true,false); > EVT VT = isPPC64 ? MVT::i64 : MVT::i32; > SDValue FIN = DAG.getFrameIndex(FI, VT); > TailCallArgumentInfo Info; > @@ -3224,7 +3227,8 @@ > // Find out what the fix offset of the frame pointer save area. > int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, > isDarwinABI); > // Allocate the frame index for frame pointer save area. > - RASI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > LROffset); > + RASI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > LROffset, > + true, false); > // Save the result. > FI->setReturnAddrSaveIndex(RASI); > } > @@ -3250,7 +3254,8 @@ > > isDarwinABI); > > // Allocate the frame index for frame pointer save area. > - FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > FPOffset); > + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > FPOffset, > + true, false); > // Save the result. > FI->setFramePointerSaveIndex(FPSI); > } > @@ -3411,7 +3416,7 @@ > // then lfd it and fcfid it. > MachineFunction &MF = DAG.getMachineFunction(); > MachineFrameInfo *FrameInfo = MF.getFrameInfo(); > - int FrameIdx = FrameInfo->CreateStackObject(8, 8); > + int FrameIdx = FrameInfo->CreateStackObject(8, 8, false); > EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); > SDValue FIdx = DAG.getFrameIndex(FrameIdx, PtrVT); > > @@ -3469,7 +3474,7 @@ > SDValue Chain = DAG.getNode(PPCISD::MFFS, dl, NodeTys, &InFlag, 0); > > // Save FP register to stack slot > - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); > + int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8, false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT); > SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Chain, > StackSlot, NULL, 0); > @@ -4137,7 +4142,7 @@ > DebugLoc dl = Op.getDebugLoc(); > // Create a stack slot that is 16-byte aligned. > MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo > (); > - int FrameIdx = FrameInfo->CreateStackObject(16, 16); > + int FrameIdx = FrameInfo->CreateStackObject(16, 16, false); > EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); > SDValue FIdx = DAG.getFrameIndex(FrameIdx, PtrVT); > > > Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1043,7 +1043,8 @@ > int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, > > isDarwinABI); > // Allocate the frame index for frame pointer save area. > - FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > FPOffset); > + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, > FPOffset, > + true, false); > // Save the result. > FI->setFramePointerSaveIndex(FPSI); > } > @@ -1051,7 +1052,8 @@ > // Reserve stack space to move the linkage area to in case of a > tail call. > int TCSPDelta = 0; > if (PerformTailCallOpt && (TCSPDelta = FI->getTailCallSPDelta()) < > 0) { > - MF.getFrameInfo()->CreateFixedObject(-1 * TCSPDelta, TCSPDelta); > + MF.getFrameInfo()->CreateFixedObject(-1 * TCSPDelta, TCSPDelta, > + true, false); > } > > // Reserve a slot closest to SP or frame pointer if we have a > dynalloc or > @@ -1067,7 +1069,8 @@ > const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; > const TargetRegisterClass *RC = IsPPC64 ? G8RC : GPRC; > RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize > (), > - RC- > >getAlignment())); > + RC- > >getAlignment(), > + false)); > } > } > > @@ -1711,7 +1714,7 @@ > return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8; > } > > -unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) > const { > +unsigned PPCRegisterInfo::getFrameRegister(const MachineFunction > &MF) const { > if (!Subtarget.isPPC64()) > return hasFP(MF) ? PPC::R31 : PPC::R1; > else > > Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -129,7 +129,8 @@ > } > InVals.push_back(Arg); > } else { > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset, > + true, > false); > SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); > SDValue Load; > if (ObjectVT == MVT::i32) { > @@ -163,7 +164,8 @@ > Arg = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::f32, Arg); > InVals.push_back(Arg); > } else { > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset, > + true, > false); > SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); > SDValue Load = DAG.getLoad(MVT::f32, dl, Chain, FIPtr, NULL, > 0); > InVals.push_back(Load); > @@ -184,7 +186,8 @@ > MF.getRegInfo().addLiveIn(*CurArgReg++, VRegHi); > HiVal = DAG.getCopyFromReg(Chain, dl, VRegHi, MVT::i32); > } else { > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset, > + true, > false); > SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); > HiVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); > } > @@ -195,7 +198,8 @@ > MF.getRegInfo().addLiveIn(*CurArgReg++, VRegLo); > LoVal = DAG.getCopyFromReg(Chain, dl, VRegLo, MVT::i32); > } else { > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset+4); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset+4, > + true, > false); > SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); > LoVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); > } > @@ -227,7 +231,8 @@ > MF.getRegInfo().addLiveIn(*CurArgReg, VReg); > SDValue Arg = DAG.getCopyFromReg(DAG.getRoot(), dl, VReg, > MVT::i32); > > - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset); > + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, > ArgOffset, > + true, > false); > SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); > > OutChains.push_back(DAG.getStore(DAG.getRoot(), dl, Arg, > FIPtr, NULL, 0)); > > Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -329,7 +329,7 @@ > // Create the nodes corresponding to a load from this > parameter slot. > // Create the frame index object for this incoming parameter... > int FI = MFI->CreateFixedObject(LocVT.getSizeInBits()/8, > - VA.getLocMemOffset()); > + VA.getLocMemOffset(), true, > false); > > // Create the SelectionDAG nodes corresponding to a load > // from this parameter > > Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Nov 12 14:49:22 2009 > @@ -1493,7 +1493,7 @@ > EVT ResVT = RVLocs[0].getValVT(); > unsigned Opc = ResVT == MVT::f32 ? X86::ST_Fp80m32 : > X86::ST_Fp80m64; > unsigned MemSize = ResVT.getSizeInBits()/8; > - int FI = MFI.CreateStackObject(MemSize, MemSize); > + int FI = MFI.CreateStackObject(MemSize, MemSize, false); > addFrameReference(BuildMI(MBB, DL, TII.get(Opc)), FI).addReg > (ResultReg); > DstRC = ResVT == MVT::f32 > ? X86::FR32RegisterClass : X86::FR64RegisterClass; > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -1381,7 +1381,7 @@ > // In case of tail call optimization mark all arguments mutable. > Since they > // could be overwritten by lowering of arguments in case of a tail > call. > int FI = MFI->CreateFixedObject(ValVT.getSizeInBits()/8, > - VA.getLocMemOffset(), isImmutable); > + VA.getLocMemOffset(), > isImmutable, false); > SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); > if (Flags.isByVal()) > return FIN; > @@ -1510,7 +1510,7 @@ > // the start of the first vararg value... for expansion of > llvm.va_start. > if (isVarArg) { > if (Is64Bit || CallConv != CallingConv::X86_FastCall) { > - VarArgsFrameIndex = MFI->CreateFixedObject(1, StackSize); > + VarArgsFrameIndex = MFI->CreateFixedObject(1, StackSize, > true, false); > } > if (Is64Bit) { > unsigned TotalNumIntRegs = 0, TotalNumXMMRegs = 0; > @@ -1561,7 +1561,8 @@ > VarArgsGPOffset = NumIntRegs * 8; > VarArgsFPOffset = TotalNumIntRegs * 8 + NumXMMRegs * 16; > RegSaveFrameIndex = MFI->CreateStackObject(TotalNumIntRegs * 8 + > - TotalNumXMMRegs * > 16, 16); > + TotalNumXMMRegs * > 16, 16, > + false); > > // Store the integer parameter registers. > SmallVector MemOps; > @@ -1682,7 +1683,8 @@ > // Calculate the new stack slot for the return address. > int SlotSize = Is64Bit ? 8 : 4; > int NewReturnAddrFI = > - MF.getFrameInfo()->CreateFixedObject(SlotSize, FPDiff-SlotSize); > + MF.getFrameInfo()->CreateFixedObject(SlotSize, FPDiff-SlotSize, > + true, false); > EVT VT = Is64Bit ? MVT::i64 : MVT::i32; > SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); > Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx, > @@ -1895,7 +1897,7 @@ > // Create frame index. > int32_t Offset = VA.getLocMemOffset()+FPDiff; > uint32_t OpSize = (VA.getLocVT().getSizeInBits()+7)/8; > - FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); > + FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset, > true, false); > FIN = DAG.getFrameIndex(FI, getPointerTy()); > > if (Flags.isByVal()) { > @@ -2180,7 +2182,8 @@ > if (ReturnAddrIndex == 0) { > // Set up a frame object for the return address. > uint64_t SlotSize = TD->getPointerSize(); > - ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject > (SlotSize, -SlotSize); > + ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject > (SlotSize, -SlotSize, > + true, > false); > FuncInfo->setRAIndex(ReturnAddrIndex); > } > > @@ -4971,7 +4974,7 @@ > DebugLoc dl = Op.getDebugLoc(); > unsigned Size = SrcVT.getSizeInBits()/8; > MachineFunction &MF = DAG.getMachineFunction(); > - int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); > + int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size, false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); > SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand > (0), > StackSlot, > @@ -5005,7 +5008,7 @@ > // shouldn't be necessary except that RFP cannot be live across > // multiple blocks. When stackifier is fixed, they can be > uncoupled. > MachineFunction &MF = DAG.getMachineFunction(); > - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); > + int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8, false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); > Tys = DAG.getVTList(MVT::Other); > SmallVector Ops; > @@ -5215,7 +5218,7 @@ > // stack slot. > MachineFunction &MF = DAG.getMachineFunction(); > unsigned MemSize = DstTy.getSizeInBits()/8; > - int SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize); > + int SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize, > false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); > > unsigned Opc; > @@ -5238,7 +5241,7 @@ > }; > Value = DAG.getNode(X86ISD::FLD, dl, Tys, Ops, 3); > Chain = Value.getValue(1); > - SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize); > + SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize, > false); > StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); > } > > @@ -6762,7 +6765,7 @@ > DebugLoc dl = Op.getDebugLoc(); > > // Save FP Control Word to stack slot > - int SSFI = MF.getFrameInfo()->CreateStackObject(2, StackAlignment); > + int SSFI = MF.getFrameInfo()->CreateStackObject(2, > StackAlignment, false); > SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); > > SDValue Chain = DAG.getNode(X86ISD::FNSTCW16m, dl, MVT::Other, > @@ -7987,7 +7990,7 @@ > // Change the floating point control register to use "round > towards zero" > // mode when truncating to an integer value. > MachineFunction *F = BB->getParent(); > - int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2); > + int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2, > false); > addFrameReference(BuildMI(BB, DL, TII->get(X86::FNSTCW16m)), > CWFrameIdx); > > // Load the old value of the high byte of the control word... > > Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -614,8 +614,8 @@ > // Offset is a 32-bit integer. > int Offset = getFrameIndexOffset(MF, FrameIndex) + > (int)(MI.getOperand(i + 3).getImm()); > - > - MI.getOperand(i + 3).ChangeToImmediate(Offset); > + > + MI.getOperand(i + 3).ChangeToImmediate(Offset); > } else { > // Offset is symbolic. This is extremely rare. > uint64_t Offset = getFrameIndexOffset(MF, FrameIndex) + > @@ -651,7 +651,8 @@ > // } > // [EBP] > MFI->CreateFixedObject(-TailCallReturnAddrDelta, > - (-1U*SlotSize)+TailCallReturnAddrDelta); > + (-1U*SlotSize)+TailCallReturnAddrDelta, > + true, false); > } > > if (hasFP(MF)) { > @@ -663,7 +664,8 @@ > int FrameIdx = MFI->CreateFixedObject(SlotSize, > -(int)SlotSize + > TFI.getOffsetOfLocalArea() + > - TailCallReturnAddrDelta); > + TailCallReturnAddrDelta, > + true, false); > assert(FrameIdx == MFI->getObjectIndexBegin() && > "Slot for EBP register must be last in order to be > found!"); > FrameIdx = 0; > @@ -1275,7 +1277,7 @@ > : X86::EIP; // Should have dwarf #8. > } > > -unsigned X86RegisterInfo::getFrameRegister(MachineFunction &MF) > const { > +unsigned X86RegisterInfo::getFrameRegister(const MachineFunction > &MF) const { > return hasFP(MF) ? FramePtr : StackPtr; > } > > > Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Thu Nov 12 > 14:49:22 2009 > @@ -860,7 +860,8 @@ > } > // Create the frame index object for this incoming parameter... > int FI = MFI->CreateFixedObject(ObjSize, > - LRSaveSize + > VA.getLocMemOffset()); > + LRSaveSize + > VA.getLocMemOffset(), > + true, false); > > // Create the SelectionDAG nodes corresponding to a load > //from this parameter > @@ -884,7 +885,7 @@ > // address > for (unsigned i = array_lengthof(ArgRegs) - 1; i >= > FirstVAReg; --i) { > // Create a stack slot > - int FI = MFI->CreateFixedObject(4, offset); > + int FI = MFI->CreateFixedObject(4, offset, true, false); > if (i == FirstVAReg) { > XFI->setVarArgsFrameIndex(FI); > } > @@ -905,7 +906,8 @@ > } else { > // This will point to the next argument passed via stack. > XFI->setVarArgsFrameIndex( > - MFI->CreateFixedObject(4, LRSaveSize + > CCInfo.getNextStackOffset())); > + MFI->CreateFixedObject(4, LRSaveSize + > CCInfo.getNextStackOffset(), > + true, false)); > } > } > > > Modified: llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp?rev=87022&r1=87021&r2=87022&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/XCore/XCoreRegisterInfo.cpp Thu Nov 12 > 14:49:22 2009 > @@ -330,9 +330,10 @@ > int FrameIdx; > if (! isVarArg) { > // A fixed offset of 0 allows us to save / restore LR using > entsp / retsp. > - FrameIdx = MFI->CreateFixedObject(RC->getSize(), 0); > + FrameIdx = MFI->CreateFixedObject(RC->getSize(), 0, true, > false); > } else { > - FrameIdx = MFI->CreateStackObject(RC->getSize(), RC- > >getAlignment()); > + FrameIdx = MFI->CreateStackObject(RC->getSize(), RC- > >getAlignment(), > + false); > } > XFI->setUsesLR(FrameIdx); > XFI->setLRSpillSlot(FrameIdx); > @@ -340,13 +341,15 @@ > if (requiresRegisterScavenging(MF)) { > // Reserve a slot close to SP or frame pointer. > RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), > - RC->getAlignment())); > + RC- > >getAlignment(), > + false)); > } > if (hasFP(MF)) { > // A callee save register is used to hold the FP. > // This needs saving / restoring in the epilogue / prologue. > XFI->setFPSpillSlot(MFI->CreateStackObject(RC->getSize(), > - RC->getAlignment())); > + RC->getAlignment(), > + false)); > } > } > > @@ -593,7 +596,7 @@ > return XCoreGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); > } > > -unsigned XCoreRegisterInfo::getFrameRegister(MachineFunction &MF) > const { > +unsigned XCoreRegisterInfo::getFrameRegister(const MachineFunction > &MF) const { > bool FP = hasFP(MF); > > return FP ? XCore::R10 : XCore::SP; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Thu Nov 12 19:01:59 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 13 Nov 2009 01:01:59 -0000 Subject: [llvm-commits] [llvm] r87049 - /llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Message-ID: <200911130101.nAD11xf5017849@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 12 19:01:58 2009 New Revision: 87049 URL: http://llvm.org/viewvc/llvm-project?rev=87049&view=rev Log: Update test. Modified: llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Modified: llvm/trunk/test/CodeGen/X86/tailcallstack64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tailcallstack64.ll?rev=87049&r1=87048&r2=87049&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tailcallstack64.ll (original) +++ llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Thu Nov 12 19:01:58 2009 @@ -5,10 +5,10 @@ ; CHECK: movl %edi, %eax ; Move param %in1 to temp register (%r10d). ; CHECK: movl 40(%rsp), %r10d -; Move param %in2 to stack. -; CHECK: movl %r10d, 32(%rsp) ; Move result of addition to stack. ; CHECK: movl %eax, 40(%rsp) +; Move param %in2 to stack. +; CHECK: movl %r10d, 32(%rsp) ; Eventually, do a TAILCALL ; CHECK: TAILCALL From bob.wilson at apple.com Thu Nov 12 19:02:34 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 12 Nov 2009 17:02:34 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> Message-ID: <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> It's breaking something on ARM, too. I'll revert it for now. I did run gcc's compat tests, but not on PPC. I guess I'll need to do that. On Nov 12, 2009, at 4:44 PM, Dale Johannesen wrote: > > On Nov 11, 2009, at 3:05 PMPST, Bob Wilson wrote: > >> Author: bwilson >> Date: Wed Nov 11 17:05:45 2009 >> New Revision: 86892 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev >> Log: >> Fix pr5406: When passing an aggregate in integer registers, the >> data cannot >> be split up into integer types smaller than the target registers. >> Most of >> the data is put into an array of i32 or i64 values, and that part >> is OK. But, >> if the size is not a multiple of 32 or 64, there may be some >> leftover bytes >> to be passed separately. Change to pass those leftover bytes in a >> single >> integer. The x86_64 target already does this in target-specific >> code. >> This also fixes radars 7226380 and 7226213. > > This patch broke binary compatibility on Darwin PPC, as shown by > running gcc's struct-layout-1 tests to compare against the installed > compiler. (The last 2 bytes of a 6-byte struct (for example) are > passed left justified within a word on that target.) > From daniel at zuster.org Thu Nov 12 19:04:59 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Nov 2009 17:04:59 -0800 Subject: [llvm-commits] [llvm] r87030 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp In-Reply-To: References: <200911122107.nACL7s2h009469@zion.cs.uiuc.edu> <6a8523d60911121626u1a43d64av5fe3de121890a091@mail.gmail.com> Message-ID: <6a8523d60911121704j24fc86abg3db33e3829665d1e@mail.gmail.com> It looks like things are coming back to happy. I made a test fix in r87049 that I don't really understand why it changed, but it seems fine. - Daniel On Thu, Nov 12, 2009 at 4:30 PM, Bill Wendling wrote: > I'm in the process of doing a revert now. I'm just going to revert the > patches that David committed during that time: > > for i in -87034 -87030 -87029 -87028 -87027 -87026 -87025 -87022 ; do > echo $ svn merge -c $i https://llvm.org/svn/llvm-project/llvm/trunk > svn merge -c $i https://llvm.org/svn/llvm-project/llvm/trunk > done > > -bw > > On Nov 12, 2009, at 4:26 PM, Daniel Dunbar wrote: > >> Hi David, >> >> I think something in this commit sequence broke things, the buildbots >> are failing everywhere. I'm going to revert-crazy as soon as I figure >> out what to revert unless you beat me to it with a fix. :) >> >> - Daniel >> >> On Thu, Nov 12, 2009 at 1:07 PM, David Greene >> wrote: >>> >>> Author: greened >>> Date: Thu Nov 12 15:07:54 2009 >>> New Revision: 87030 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=87030&view=rev >>> Log: >>> >>> Set the ReloadReuse AsmPrinter flag where appropriate. >>> >>> Modified: >>> ? llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp >>> >>> Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=87030&r1=87029&r2=87030&view=diff >>> >>> >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Nov 12 15:07:54 2009 >>> @@ -1704,6 +1704,7 @@ >>> >>> ? ? ? ? ? ?// Mark is killed. >>> ? ? ? ? ? ?MachineInstr *CopyMI = prior(InsertLoc); >>> + ? ? ? ? ? ?CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >>> ? ? ? ? ? ?MachineOperand *KillOpnd = >>> CopyMI->findRegisterUseOperand(InReg); >>> ? ? ? ? ? ?KillOpnd->setIsKill(); >>> ? ? ? ? ? ?UpdateKills(*CopyMI, TRI, RegKills, KillOps); >>> @@ -1984,6 +1985,7 @@ >>> ? ? ? ? ?TII->copyRegToReg(MBB, InsertLoc, DesignatedReg, PhysReg, RC, >>> RC); >>> >>> ? ? ? ? ?MachineInstr *CopyMI = prior(InsertLoc); >>> + ? ? ? ? ?CopyMI->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >>> ? ? ? ? ?UpdateKills(*CopyMI, TRI, RegKills, KillOps); >>> >>> ? ? ? ? ?// This invalidates DesignatedReg. >>> @@ -2112,6 +2114,7 @@ >>> ? ? ? ? ? ? ? ?// virtual or needing to clobber any values if it's >>> physical). >>> ? ? ? ? ? ? ? ?NextMII = &MI; >>> ? ? ? ? ? ? ? ?--NextMII; ?// backtrack to the copy. >>> + ? ? ? ? ? ? ? ?NextMII->setAsmPrinterFlag(AsmPrinter::ReloadReuse); >>> ? ? ? ? ? ? ? ?// Propagate the sub-register index over. >>> ? ? ? ? ? ? ? ?if (SubIdx) { >>> ? ? ? ? ? ? ? ? ?DefMO = NextMII->findRegisterDefOperand(DestReg); >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From dalej at apple.com Thu Nov 12 19:08:54 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 12 Nov 2009 17:08:54 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> Message-ID: On Nov 12, 2009, at 4:44 PMPST, Dale Johannesen wrote: > > On Nov 11, 2009, at 3:05 PMPST, Bob Wilson wrote: > >> Author: bwilson >> Date: Wed Nov 11 17:05:45 2009 >> New Revision: 86892 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev >> Log: >> Fix pr5406: When passing an aggregate in integer registers, the >> data cannot >> be split up into integer types smaller than the target registers. >> Most of >> the data is put into an array of i32 or i64 values, and that part >> is OK. But, >> if the size is not a multiple of 32 or 64, there may be some >> leftover bytes >> to be passed separately. Change to pass those leftover bytes in a >> single >> integer. The x86_64 target already does this in target-specific >> code. >> This also fixes radars 7226380 and 7226213. > > This patch broke binary compatibility on Darwin PPC, as shown by > running gcc's struct-layout-1 tests to compare against the installed > compiler. (The last 2 bytes of a 6-byte struct (for example) are > passed left justified within a word on that target.) Also, can't this result in reading bytes off the end of the struct? That isn't safe if the load crosses a page boundary. From bob.wilson at apple.com Thu Nov 12 19:10:29 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Nov 2009 01:10:29 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r87052 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <200911130110.nAD1ATXD026957@zion.cs.uiuc.edu> Author: bwilson Date: Thu Nov 12 19:10:29 2009 New Revision: 87052 URL: http://llvm.org/viewvc/llvm-project?rev=87052&view=rev Log: Revert 86892. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=87052&r1=87051&r2=87052&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Thu Nov 12 19:10:29 2009 @@ -629,18 +629,19 @@ Elts.push_back(ATy); } - // Put any left over bytes into one last register. This target-independent - // code does not know the size of the argument registers, so use the - // smallest size that will work. - if (Size > 4) { - Elts.push_back(Type::getInt64Ty(getGlobalContext())); - } else if (Size > 2) { + if (Size >= 4) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - } else if (Size > 1) { + Size -= 4; + } + if (Size >= 2) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - } else { + Size -= 2; + } + if (Size >= 1) { Elts.push_back(Type::getInt8Ty(getGlobalContext())); + Size -= 1; } + assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1072,18 +1073,19 @@ Elts.push_back(ATy); } - // Put any left over bytes into one last register. This target-independent - // code does not know the size of the argument registers, so use the - // smallest size that will work. - if (Size > 4) { - Elts.push_back(Type::getInt64Ty(getGlobalContext())); - } else if (Size > 2) { + if (Size >= 4) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - } else if (Size > 1) { + Size -= 4; + } + if (Size >= 2) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - } else { + Size -= 2; + } + if (Size >= 1) { Elts.push_back(Type::getInt8Ty(getGlobalContext())); + Size -= 1; } + assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; From bob.wilson at apple.com Thu Nov 12 19:14:04 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 12 Nov 2009 17:14:04 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> Message-ID: <2B600EA9-70CC-4F95-877E-2B27730964F1@apple.com> On Nov 12, 2009, at 5:08 PM, Dale Johannesen wrote: > > On Nov 12, 2009, at 4:44 PMPST, Dale Johannesen wrote: > >> >> On Nov 11, 2009, at 3:05 PMPST, Bob Wilson wrote: >> >>> Author: bwilson >>> Date: Wed Nov 11 17:05:45 2009 >>> New Revision: 86892 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev >>> Log: >>> Fix pr5406: When passing an aggregate in integer registers, the >>> data cannot >>> be split up into integer types smaller than the target registers. >>> Most of >>> the data is put into an array of i32 or i64 values, and that part >>> is OK. But, >>> if the size is not a multiple of 32 or 64, there may be some >>> leftover bytes >>> to be passed separately. Change to pass those leftover bytes in a >>> single >>> integer. The x86_64 target already does this in target-specific >>> code. >>> This also fixes radars 7226380 and 7226213. >> >> This patch broke binary compatibility on Darwin PPC, as shown by >> running gcc's struct-layout-1 tests to compare against the >> installed compiler. (The last 2 bytes of a 6-byte struct (for >> example) are passed left justified within a word on that target.) > > Also, can't this result in reading bytes off the end of the struct? > That isn't safe if the load crosses a page boundary. > You may very well be right. I was following the precedent of the x86-64 code, which has this comment: /// .... This means we'll be loading bytes off the end of the object /// in some cases. That's what gcc does, so it must be OK, right? Right? (before the llvm_x86_should_pass_aggregate_in_integer_regs function). From dalej at apple.com Thu Nov 12 19:15:39 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 12 Nov 2009 17:15:39 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <2B600EA9-70CC-4F95-877E-2B27730964F1@apple.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <2B600EA9-70CC-4F95-877E-2B27730964F1@apple.com> Message-ID: <6836AE0C-80A9-4873-ACC4-8EBE1C164BD3@apple.com> On Nov 12, 2009, at 5:14 PMPST, Bob Wilson wrote: >> >> Also, can't this result in reading bytes off the end of the >> struct? That isn't safe if the load crosses a page boundary. > > You may very well be right. I was following the precedent of the > x86-64 code, which has this comment: > > /// .... This means we'll be loading bytes off the end of the object > /// in some cases. That's what gcc does, so it must be OK, right? > Right? > > (before the llvm_x86_should_pass_aggregate_in_integer_regs function). Ah, well, I wrote that comment, so feel free to do it right:) From grosbach at apple.com Thu Nov 12 19:17:22 2009 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Nov 2009 01:17:22 -0000 Subject: [llvm-commits] [llvm] r87054 - /llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Message-ID: <200911130117.nAD1HMK2027241@zion.cs.uiuc.edu> Author: grosbach Date: Thu Nov 12 19:17:22 2009 New Revision: 87054 URL: http://llvm.org/viewvc/llvm-project?rev=87054&view=rev Log: use lower case for readability Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=87054&r1=87053&r2=87054&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Thu Nov 12 19:17:22 2009 @@ -422,7 +422,7 @@ // to APSR. let Defs = [CPSR], Uses = [FPSCR] in def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs", - "\tAPSR_nzcv, FPSCR", + "\tapsr_nzcv, fpscr", [(arm_fmstat)]> { let Inst{27-20} = 0b11101111; let Inst{19-16} = 0b0001; From grosbach at apple.com Thu Nov 12 19:19:25 2009 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Nov 2009 01:19:25 -0000 Subject: [llvm-commits] [llvm] r87056 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911130119.nAD1JP4M027336@zion.cs.uiuc.edu> Author: grosbach Date: Thu Nov 12 19:19:24 2009 New Revision: 87056 URL: http://llvm.org/viewvc/llvm-project?rev=87056&view=rev Log: Block renumbering Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=87056&r1=87055&r2=87056&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Nov 12 19:19:24 2009 @@ -1804,9 +1804,7 @@ JTBB->addSuccessor(NewBB); // Update internal data structures to account for the newly inserted MBB. - // This is almost the same as UpdateForInsertedWaterBlock, except that - // the Water goes after OrigBB, not NewBB. - MF.RenumberBlocks(NewBB); + MF.RenumberBlocks(); // Insert a size into BBSizes to align it properly with the (newly // renumbered) block numbers. From rafael.espindola at gmail.com Thu Nov 12 19:24:40 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 Nov 2009 01:24:40 -0000 Subject: [llvm-commits] [llvm] r87058 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp Message-ID: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> Author: rafael Date: Thu Nov 12 19:24:40 2009 New Revision: 87058 URL: http://llvm.org/viewvc/llvm-project?rev=87058&view=rev Log: Add a new split method to StringRef that puts the substrings in a vector. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/unittests/ADT/StringRefTest.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=87058&r1=87057&r2=87058&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 19:24:40 2009 @@ -15,6 +15,14 @@ #include #include +namespace std { + template + class allocator; + + template + class vector; +} + namespace llvm { /// StringRef - Represent a constant reference to a string, i.e. a character @@ -314,6 +322,25 @@ return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos)); } + /// split - Split into substrings around the occurences of a separator + /// string. + /// + /// Each substring is stored in \arg A. If \arg MaxSplit is >= 0, at most + /// \arg MaxSplit splits are done and consequently <= \arg MaxSplit + /// elements are added to A. + /// If \arg KeepEmpty is false, empty strings are not added to \arg A. They + /// still count when considering \arg MaxSplit + /// An useful invariant is that + /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true + /// + /// \param A - Where to put the substrings. + /// \param Separator - The string to split on. + /// \param MaxSplit - The maximum number of times the string is split. + /// \parm KeepEmpty - True if empty substring should be added. + void split(std::vector > &A, + StringRef Separator, unsigned MaxSplit = -1, + bool KeepEmpty = true) const; + /// rsplit - Split into two substrings around the last occurence of a /// separator character. /// Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=87058&r1=87057&r2=87058&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Thu Nov 12 19:24:40 2009 @@ -56,3 +56,22 @@ S2 = getToken(S, Delimiters); } } + +void llvm::StringRef::split(std::vector &A, + StringRef Separators, unsigned MaxSplit, + bool KeepEmpty) const { + StringRef rest = *this; + + for (unsigned splits = 0; + rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit); + ++splits) { + std::pair p = rest.split(Separators); + + if (p.first.size() != 0 || KeepEmpty) + A.push_back(p.first); + rest = p.second; + } + + if (rest.size() != 0 || KeepEmpty) + A.push_back(rest); +} Modified: llvm/trunk/unittests/ADT/StringRefTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringRefTest.cpp?rev=87058&r1=87057&r2=87058&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/StringRefTest.cpp (original) +++ llvm/trunk/unittests/ADT/StringRefTest.cpp Thu Nov 12 19:24:40 2009 @@ -110,6 +110,81 @@ Str.rsplit('o')); } +TEST(StringRefTest, Split2) { + std::vector parts; + std::vector expected; + + expected.push_back("ab"); expected.push_back("c"); + StringRef(",ab,,c,").split(parts, ",", -1, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back(""); expected.push_back("ab"); expected.push_back(""); + expected.push_back("c"); expected.push_back(""); + StringRef(",ab,,c,").split(parts, ",", -1, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back(""); + StringRef("").split(parts, ",", -1, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + StringRef("").split(parts, ",", -1, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + StringRef(",").split(parts, ",", -1, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back(""); expected.push_back(""); + StringRef(",").split(parts, ",", -1, true); + EXPECT_TRUE(parts == expected); + + // Test MaxSplit + expected.clear(); parts.clear(); + expected.push_back("a,,b,c"); + StringRef("a,,b,c").split(parts, ",", 0, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a,,b,c"); + StringRef("a,,b,c").split(parts, ",", 0, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back(",b,c"); + StringRef("a,,b,c").split(parts, ",", 1, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back(",b,c"); + StringRef("a,,b,c").split(parts, ",", 1, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back(""); expected.push_back("b,c"); + StringRef("a,,b,c").split(parts, ",", 2, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back("b,c"); + StringRef("a,,b,c").split(parts, ",", 2, false); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back(""); expected.push_back("b"); + expected.push_back("c"); + StringRef("a,,b,c").split(parts, ",", 3, true); + EXPECT_TRUE(parts == expected); + + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back("b"); expected.push_back("c"); + StringRef("a,,b,c").split(parts, ",", 3, false); + EXPECT_TRUE(parts == expected); +} + TEST(StringRefTest, StartsWith) { StringRef Str("hello"); EXPECT_TRUE(Str.startswith("he")); From clattner at apple.com Thu Nov 12 19:31:03 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 17:31:03 -0800 Subject: [llvm-commits] [llvm] r87058 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp In-Reply-To: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> References: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> Message-ID: <54F0BD43-03F6-4834-A60B-FB30DC3800CC@apple.com> On Nov 12, 2009, at 5:24 PM, Rafael Espindola wrote: > Author: rafael > Date: Thu Nov 12 19:24:40 2009 > New Revision: 87058 > > URL: http://llvm.org/viewvc/llvm-project?rev=87058&view=rev > Log: > Add a new split method to StringRef that puts the substrings in a > vector. Any reason not to put them into a SmallVectorImpl? -Chris From clattner at apple.com Thu Nov 12 19:33:41 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 17:33:41 -0800 Subject: [llvm-commits] [llvm] r87022 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ In-Reply-To: References: <200911122049.nACKnPDw008707@zion.cs.uiuc.edu> Message-ID: <414E9A00-5B67-4C06-9FC2-E9C63AA1BF11@apple.com> On Nov 12, 2009, at 5:00 PM, Evan Cheng wrote: > Why is this necessary? As of 84326 each StackObject already has a > isSpillSlot bool field. Right, the API changes look good here, but the data structure changes in MachineFrameInfo do not. -Chris From clattner at apple.com Thu Nov 12 19:36:05 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 Nov 2009 17:36:05 -0800 Subject: [llvm-commits] [llvm] r87047 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h In-Reply-To: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> References: <200911130029.nAD0TrBe016856@zion.cs.uiuc.edu> Message-ID: <6F1EFAA8-1637-4971-9423-A085123A3F0E@apple.com> On Nov 12, 2009, at 4:29 PM, David Greene wrote: > Author: greened > Date: Thu Nov 12 18:29:53 2009 > New Revision: 87047 > > URL: http://llvm.org/viewvc/llvm-project?rev=87047&view=rev > Log: > > Fix a bootstrap failure. > > Provide special isLoadFromStackSlotPostFE and isStoreToStackSlotPostFE > interfaces to explicitly request checking for post-frame ptr > elimination > operands. This uses a heuristic so it isn't reliable for correctness. Hi David, Aside from Bill's rage :), I really don't think that this is the right approach. The code generator should already have this information from MemOperands and we generally prefer to have fewer (not more) random target hooks. I really don't like having to implement two different target hooks that are slightly different. -Chris From espindola at google.com Thu Nov 12 19:42:44 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 12 Nov 2009 20:42:44 -0500 Subject: [llvm-commits] [llvm] r87058 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp In-Reply-To: <54F0BD43-03F6-4834-A60B-FB30DC3800CC@apple.com> References: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> <54F0BD43-03F6-4834-A60B-FB30DC3800CC@apple.com> Message-ID: <38a0d8450911121742h44b19dcfya1e7037cdef6fed1@mail.gmail.com> > Any reason not to put them into a SmallVectorImpl? I started by copying Daniel's std::vector forward declaration. Will take a look at what it would look like with SmallVector. > -Chris Cheers, -- Rafael ?vila de Esp?ndola From vhernandez at apple.com Thu Nov 12 19:44:55 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 13 Nov 2009 01:44:55 -0000 Subject: [llvm-commits] [llvm] r87059 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <200911130144.nAD1itY1028121@zion.cs.uiuc.edu> Author: hernande Date: Thu Nov 12 19:44:55 2009 New Revision: 87059 URL: http://llvm.org/viewvc/llvm-project?rev=87059&view=rev Log: Remove unnecessary llvm.dbg.declare bitcast Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=87059&r1=87058&r2=87059&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Nov 12 19:44:55 2009 @@ -467,7 +467,6 @@ LLVMContext& VMContext; // Cached values for uniquing and faster lookups. - const Type *EmptyStructPtr; // "{}*". Function *StopPointFn; // llvm.dbg.stoppoint Function *FuncStartFn; // llvm.dbg.func.start Function *RegionStartFn; // llvm.dbg.region.start Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=87059&r1=87058&r2=87059&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu Nov 12 19:44:55 2009 @@ -608,9 +608,7 @@ DIFactory::DIFactory(Module &m) : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), - DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); -} + DeclareFn(0) {} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1037,10 +1035,7 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - Instruction *InsertBefore) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); - + Instruction *InsertBefore) { if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); @@ -1050,10 +1045,7 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); - + BasicBlock *InsertAtEnd) { if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); From dalej at apple.com Thu Nov 12 19:45:18 2009 From: dalej at apple.com (Dale Johannesen) Date: Fri, 13 Nov 2009 01:45:18 -0000 Subject: [llvm-commits] [llvm] r87060 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp test/CodeGen/PowerPC/vec_splat_constant.ll Message-ID: <200911130145.nAD1jIXl028149@zion.cs.uiuc.edu> Author: johannes Date: Thu Nov 12 19:45:18 2009 New Revision: 87060 URL: http://llvm.org/viewvc/llvm-project?rev=87060&view=rev Log: Adjust isConstantSplat to allow for big-endian targets. PPC is such a target; make it work. Added: llvm/trunk/test/CodeGen/PowerPC/vec_splat_constant.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=87060&r1=87059&r2=87060&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Thu Nov 12 19:45:18 2009 @@ -1953,10 +1953,10 @@ /// that value are zero, and the corresponding bits in the SplatUndef mask /// are set. The SplatBitSize value is set to the splat element size in /// bits. HasAnyUndefs is set to true if any bits in the vector are - /// undefined. + /// undefined. isBigEndian describes the endianness of the target. bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, - unsigned MinSplatBits = 0); + unsigned MinSplatBits = 0, bool isBigEndian = false); static inline bool classof(const BuildVectorSDNode *) { return true; } static inline bool classof(const SDNode *N) { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=87060&r1=87059&r2=87060&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Nov 12 19:45:18 2009 @@ -5916,7 +5916,8 @@ APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, - unsigned MinSplatBits) { + unsigned MinSplatBits, + bool isBigEndian) { EVT VT = getValueType(0); assert(VT.isVector() && "Expected a vector type"); unsigned sz = VT.getSizeInBits(); @@ -5933,12 +5934,14 @@ unsigned int nOps = getNumOperands(); assert(nOps > 0 && "isConstantSplat has 0-size build vector"); unsigned EltBitSize = VT.getVectorElementType().getSizeInBits(); - for (unsigned i = 0; i < nOps; ++i) { + + for (unsigned j = 0; j < nOps; ++j) { + unsigned i = isBigEndian ? nOps-1-j : j; SDValue OpVal = getOperand(i); - unsigned BitPos = i * EltBitSize; + unsigned BitPos = j * EltBitSize; if (OpVal.getOpcode() == ISD::UNDEF) - SplatUndef |= APInt::getBitsSet(sz, BitPos, BitPos +EltBitSize); + SplatUndef |= APInt::getBitsSet(sz, BitPos, BitPos + EltBitSize); else if (ConstantSDNode *CN = dyn_cast(OpVal)) SplatValue |= (APInt(CN->getAPIntValue()).zextOrTrunc(EltBitSize). zextOrTrunc(sz) << BitPos); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=87060&r1=87059&r2=87060&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Nov 12 19:45:18 2009 @@ -637,7 +637,7 @@ unsigned BitSize; bool HasAnyUndefs; - if (BV->isConstantSplat(APVal, APUndef, BitSize, HasAnyUndefs, 32)) + if (BV->isConstantSplat(APVal, APUndef, BitSize, HasAnyUndefs, 32, true)) if (ConstantFPSDNode *CFP = dyn_cast(N->getOperand(0))) return CFP->getValueAPF().isNegZero(); @@ -3672,7 +3672,7 @@ unsigned SplatBitSize; bool HasAnyUndefs; if (! BVN->isConstantSplat(APSplatBits, APSplatUndef, SplatBitSize, - HasAnyUndefs) || SplatBitSize > 32) + HasAnyUndefs, 0, true) || SplatBitSize > 32) return SDValue(); unsigned SplatBits = APSplatBits.getZExtValue(); Added: llvm/trunk/test/CodeGen/PowerPC/vec_splat_constant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/vec_splat_constant.ll?rev=87060&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/vec_splat_constant.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/vec_splat_constant.ll Thu Nov 12 19:45:18 2009 @@ -0,0 +1,24 @@ +; RUN: llc < %s -march=ppc32 -mtriple=powerpc-apple-darwin -mcpu=g5 | FileCheck %s +; Formerly incorrectly inserted vsldoi (endian confusion) + + at baz = common global <16 x i8> zeroinitializer ; <<16 x i8>*> [#uses=1] + +define void @foo(<16 x i8> %x) nounwind ssp { +entry: +; CHECK: _foo: +; CHECK-NOT: vsldoi + %x_addr = alloca <16 x i8> ; <<16 x i8>*> [#uses=2] + %temp = alloca <16 x i8> ; <<16 x i8>*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store <16 x i8> %x, <16 x i8>* %x_addr + store <16 x i8> , <16 x i8>* %temp, align 16 + %0 = load <16 x i8>* %x_addr, align 16 ; <<16 x i8>> [#uses=1] + %1 = load <16 x i8>* %temp, align 16 ; <<16 x i8>> [#uses=1] + %tmp = add <16 x i8> %0, %1 ; <<16 x i8>> [#uses=1] + store <16 x i8> %tmp, <16 x i8>* @baz, align 16 + br label %return + +return: ; preds = %entry + ret void +; CHECK: blr +} From rafael.espindola at gmail.com Thu Nov 12 20:18:25 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 Nov 2009 02:18:25 -0000 Subject: [llvm-commits] [llvm] r87068 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp Message-ID: <200911130218.nAD2IPBh029149@zion.cs.uiuc.edu> Author: rafael Date: Thu Nov 12 20:18:25 2009 New Revision: 87068 URL: http://llvm.org/viewvc/llvm-project?rev=87068&view=rev Log: Switch to smallvector. Also fix issue with using unsigend for MaxSplit. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/unittests/ADT/StringRefTest.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=87068&r1=87067&r2=87068&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 20:18:25 2009 @@ -15,15 +15,9 @@ #include #include -namespace std { - template - class allocator; - - template - class vector; -} - namespace llvm { + template + class SmallVectorImpl; /// StringRef - Represent a constant reference to a string, i.e. a character /// array and a length, which need not be null terminated. @@ -337,8 +331,8 @@ /// \param Separator - The string to split on. /// \param MaxSplit - The maximum number of times the string is split. /// \parm KeepEmpty - True if empty substring should be added. - void split(std::vector > &A, - StringRef Separator, unsigned MaxSplit = -1, + void split(SmallVectorImpl &A, + StringRef Separator, int MaxSplit = -1, bool KeepEmpty = true) const; /// rsplit - Split into two substrings around the last occurence of a Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=87068&r1=87067&r2=87068&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Thu Nov 12 20:18:25 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/SmallVector.h" #include using namespace llvm; @@ -57,12 +58,12 @@ } } -void llvm::StringRef::split(std::vector &A, - StringRef Separators, unsigned MaxSplit, +void llvm::StringRef::split(SmallVectorImpl &A, + StringRef Separators, int MaxSplit, bool KeepEmpty) const { StringRef rest = *this; - for (unsigned splits = 0; + for (int splits = 0; rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit); ++splits) { std::pair p = rest.split(Separators); Modified: llvm/trunk/unittests/ADT/StringRefTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringRefTest.cpp?rev=87068&r1=87067&r2=87068&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/StringRefTest.cpp (original) +++ llvm/trunk/unittests/ADT/StringRefTest.cpp Thu Nov 12 20:18:25 2009 @@ -9,6 +9,7 @@ #include "gtest/gtest.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -111,8 +112,8 @@ } TEST(StringRefTest, Split2) { - std::vector parts; - std::vector expected; + SmallVector parts; + SmallVector expected; expected.push_back("ab"); expected.push_back("c"); StringRef(",ab,,c,").split(parts, ",", -1, false); From devang.patel at gmail.com Thu Nov 12 20:23:52 2009 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 12 Nov 2009 18:23:52 -0800 Subject: [llvm-commits] [llvm] r87059 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp In-Reply-To: <200911130144.nAD1itY1028121@zion.cs.uiuc.edu> References: <200911130144.nAD1itY1028121@zion.cs.uiuc.edu> Message-ID: <352a1fb20911121823s1ab58f60gfd896646b64d1ee5@mail.gmail.com> Victor, On Thu, Nov 12, 2009 at 5:44 PM, Victor Hernandez wrote: > Author: hernande > Date: Thu Nov 12 19:44:55 2009 > New Revision: 87059 > > URL: http://llvm.org/viewvc/llvm-project?rev=87059&view=rev > Log: > Remove unnecessary llvm.dbg.declare bitcast This is failing following clang tests. I am reverting this for now. Failing Tests (9): Clang::CodeGen/2009-01-21-invalid-debug-info.m Clang::CodeGen/2009-07-31-DbgDeclare.c Clang::CodeGen/debug-info.c Clang::CodeGen/vector.c Clang::CodeGenCXX/PR4890-debug-info-dtor.cpp Clang::CodeGenObjC/debug-info-linkagename.m Clang::CodeGenObjC/objc2-weak-ivar-debug.m Clang::Coverage/codegen-next.m Clang::Coverage/codegen.c - Devang From dpatel at apple.com Thu Nov 12 20:25:26 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 13 Nov 2009 02:25:26 -0000 Subject: [llvm-commits] [llvm] r87069 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911130225.nAD2PRu7029355@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 12 20:25:26 2009 New Revision: 87069 URL: http://llvm.org/viewvc/llvm-project?rev=87069&view=rev Log: Ignore nameless variables. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=87069&r1=87068&r2=87069&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Nov 12 20:25:26 2009 @@ -1511,6 +1511,9 @@ DbgScope *Scope, CompileUnit *Unit) { // Get the descriptor. const DIVariable &VD = DV->getVariable(); + const char *Name = VD.getName(); + if (!Name) + return NULL; // Translate tag to proper Dwarf tag. The result variable is dropped for // now. @@ -1547,7 +1550,6 @@ dwarf::DW_FORM_ref4, AbsDIE); } else { - const char *Name = VD.getName(); AddString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); AddSourceLine(VariableDie, &VD); From dpatel at apple.com Thu Nov 12 20:27:34 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 13 Nov 2009 02:27:34 -0000 Subject: [llvm-commits] [llvm] r87070 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <200911130227.nAD2RYBw029428@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 12 20:27:33 2009 New Revision: 87070 URL: http://llvm.org/viewvc/llvm-project?rev=87070&view=rev Log: Revert r87059 for now. It is failing clang tests. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=87070&r1=87069&r2=87070&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Nov 12 20:27:33 2009 @@ -467,6 +467,7 @@ LLVMContext& VMContext; // Cached values for uniquing and faster lookups. + const Type *EmptyStructPtr; // "{}*". Function *StopPointFn; // llvm.dbg.stoppoint Function *FuncStartFn; // llvm.dbg.func.start Function *RegionStartFn; // llvm.dbg.region.start Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=87070&r1=87069&r2=87070&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu Nov 12 20:27:33 2009 @@ -608,7 +608,9 @@ DIFactory::DIFactory(Module &m) : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), - DeclareFn(0) {} + DeclareFn(0) { + EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); +} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1035,7 +1037,10 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - Instruction *InsertBefore) { + Instruction *InsertBefore) { + // Cast the storage to a {}* for the call to llvm.dbg.declare. + Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); + if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); @@ -1045,7 +1050,10 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd) { + BasicBlock *InsertAtEnd) { + // Cast the storage to a {}* for the call to llvm.dbg.declare. + Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); + if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); From vkutuzov at accesssoftek.com Thu Nov 12 21:08:57 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Thu, 12 Nov 2009 19:08:57 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options In-Reply-To: <38a0d8450911121059n6a0d3eb0ka34711d931c7675e@mail.gmail.com> References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> <38a0d8450911101625s5e3b7cb0m31ec0ce4d4144dc@mail.gmail.com> , <38a0d8450911121059n6a0d3eb0ka34711d931c7675e@mail.gmail.com> Message-ID: <6AE1604EE3EC5F4296C096518C6B77EEFD4607BA@mail.accesssoftek.com> Thanks, Rafael. I have split this patch to a set of smaller ones. Hope this will make it easier to review. Please find attached 2 patches: * one adds to the Triple class - a new getAssemblerArchName method, and - assignment operators for the std::string and StringRef types; * the other one adds to the SubtargetFeature class - a new getDefaultSubTargetTripleFeatures method (code moved from the LTOModule class), - AddFeatures methods, and - hasFeature method. I'll send the patch that use these changes after these 2 patches will be submitted. Viktor. ________________________________________ From: Rafael Espindola [espindola at google.com] Sent: Thursday, November 12, 2009 10:59 AM To: Viktor Kutuzov Cc: Commit Messages and Patches for LLVM Subject: Re: [llvm-commits] [PATCH] LTO code generator options > The updated patch is attached. > > * StringRef is passed by value; > * Removed getArchNameForLLVMArchType; > * Fixed strange alignment. > * Removed all cosmetic changes from this patch. > > Is it Ok to submit? Sorry about the delay. I am not very familiar with this code. About Triple::getArchNameForDarwinArchTriplePart. Its output is passed to the assembler, so the comment "gcc?" should probably be replaced with "architecture name used by the assembler" or something like that. Can you make it non static? So instead of Triple::getArchNameForDarwinArchTriplePart(_targetTriple.getArchName() we would have _targetTriple.getArchNameForDarwinArchTriplePart() If you move the check for "is darwin" into that method you could also rename it into something like getAssemblerArchName. The code that uses it would look like const char *arch = _targetTriple.getAssemblerArchName(); if (arch != NULL) { ... } Just have the method return NULL if it is not darwin. Finally, this part is an (very nice) independent cleanup, no? Would you mind putting it in an independent patch? > Cheers, >Viktor Thanks, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-target-override-01_triple.diff Type: application/octet-stream Size: 2537 bytes Desc: llvm-target-override-01_triple.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/c303d99c/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-target-override-02_subtargetfeature.diff Type: application/octet-stream Size: 4519 bytes Desc: llvm-target-override-02_subtargetfeature.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091112/c303d99c/attachment-0001.obj From rafael.espindola at gmail.com Thu Nov 12 22:55:09 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 Nov 2009 04:55:09 -0000 Subject: [llvm-commits] [llvm] r87084 - in /llvm/trunk: lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp Message-ID: <200911130455.nAD4t9Xt001878@zion.cs.uiuc.edu> Author: rafael Date: Thu Nov 12 22:55:09 2009 New Revision: 87084 URL: http://llvm.org/viewvc/llvm-project?rev=87084&view=rev Log: Distinguish "a," from "a". The first one splits into "a" + "" and the second one into "a" + 0. Modified: llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/unittests/ADT/StringRefTest.cpp Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=87084&r1=87083&r2=87084&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Thu Nov 12 22:55:09 2009 @@ -63,8 +63,10 @@ bool KeepEmpty) const { StringRef rest = *this; + // rest.data() is used to distinguish cases like "a," that splits into + // "a" + "" and "a" that splits into "a" + 0. for (int splits = 0; - rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit); + rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit); ++splits) { std::pair p = rest.split(Separators); @@ -72,7 +74,7 @@ A.push_back(p.first); rest = p.second; } - - if (rest.size() != 0 || KeepEmpty) + // If we have a tail left, add it. + if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty)) A.push_back(rest); } Modified: llvm/trunk/unittests/ADT/StringRefTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringRefTest.cpp?rev=87084&r1=87083&r2=87084&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/StringRefTest.cpp (original) +++ llvm/trunk/unittests/ADT/StringRefTest.cpp Thu Nov 12 22:55:09 2009 @@ -143,6 +143,11 @@ StringRef(",").split(parts, ",", -1, true); EXPECT_TRUE(parts == expected); + expected.clear(); parts.clear(); + expected.push_back("a"); expected.push_back("b"); + StringRef("a,b").split(parts, ",", -1, true); + EXPECT_TRUE(parts == expected); + // Test MaxSplit expected.clear(); parts.clear(); expected.push_back("a,,b,c"); From sebastian.redl at getdesigned.at Fri Nov 13 01:25:51 2009 From: sebastian.redl at getdesigned.at (Sebastian Redl) Date: Fri, 13 Nov 2009 08:25:51 +0100 Subject: [llvm-commits] [llvm] r87058 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringExtras.cpp unittests/ADT/StringRefTest.cpp In-Reply-To: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> References: <200911130124.nAD1Ofai027531@zion.cs.uiuc.edu> Message-ID: <4AFD09FF.6090709@getdesigned.at> Rafael Espindola wrote: > Author: rafael > Date: Thu Nov 12 19:24:40 2009 > New Revision: 87058 > > URL: http://llvm.org/viewvc/llvm-project?rev=87058&view=rev > Log: > Add a new split method to StringRef that puts the substrings in a vector. > > > ============================================================================== > --- llvm/trunk/include/llvm/ADT/StringRef.h (original) > +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 19:24:40 2009 > @@ -15,6 +15,14 @@ > #include > #include > > +namespace std { > + template > + class allocator; > + > + template > + class vector; > +} > + > You can't do that. Any standard library is allowed to declare its templates with any number of parameters, as long as all those that are not described in the standard have defaults. So this is not portable. Even if it was, you're still not allowed to forward-declare elements of the standard library yourself. (As a side note, std::allocator is given to you by anyway.) Sebastian From baldrick at free.fr Fri Nov 13 02:42:36 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 08:42:36 -0000 Subject: [llvm-commits] [dragonegg] r87098 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911130842.nAD8gaiC014061@zion.cs.uiuc.edu> Author: baldrick Date: Fri Nov 13 02:42:36 2009 New Revision: 87098 URL: http://llvm.org/viewvc/llvm-project?rev=87098&view=rev Log: Factor the version check into its own method. Make it possible to turn off the check. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=87098&r1=87097&r2=87098&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Fri Nov 13 02:42:36 2009 @@ -2063,6 +2063,19 @@ NULL // help }; +static bool version_check(struct plugin_gcc_version *gcc_version, + struct plugin_gcc_version *plugin_version) { + // Make it possible to turn off the version check - useful for testing gcc + // bootstrap. + if (getenv("dragonegg_disable_version_check")) + return true; + + // Check that the running gcc has exactly the same version as the gcc we were + // built against. This strict check seems wise when developing against a fast + // moving gcc tree. TODO: Use a milder check if doing a "release build". + return plugin_default_version_check (gcc_version, plugin_version); +} + /// plugin_init - Plugin initialization routine, called by GCC. This is the /// first code executed in the plugin (except for constructors). Configure @@ -2072,10 +2085,8 @@ const char *plugin_name = plugin_info->base_name; struct register_pass_info pass_info; - // Check that the running gcc is the same as the gcc we were built against. - // If not, refuse to load. This seems wise when developing against a fast - // moving gcc tree. TODO: Use a milder check if doing a "release build". - if (!plugin_default_version_check (version, &gcc_version)) { + // Check that the plugin is compatible with the running gcc. + if (!version_check (&gcc_version, version)) { errs() << "Incompatible plugin version\n"; return 1; } From baldrick at free.fr Fri Nov 13 04:12:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 11:12:58 +0100 Subject: [llvm-commits] [llvm] r87023 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <200911122051.nACKps7d008820@zion.cs.uiuc.edu> References: <200911122051.nACKps7d008820@zion.cs.uiuc.edu> Message-ID: <4AFD312A.2010100@free.fr> Hi Bill, > If there's more than one function operand to a call instruction, be conservative > and don't assume that the call doesn't throw. It would be nice if there were a > way to determine which is the callee and which is a parameter. In practice, the > architecture we care about normally only have one operand for a call instruction > (x86 and arm). good idea! Pity this is still not philosophically correct, i.e. does not handle the case of a nounwind call to a function that is not marked nounwind... Ciao, Duncan. From baldrick at free.fr Fri Nov 13 04:25:30 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 11:25:30 +0100 Subject: [llvm-commits] [llvm] r86897 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <0FE16449-8429-4D18-8E7D-545DBD67CFE1@apple.com> References: <200911112317.nABNH2X5011048@zion.cs.uiuc.edu> <4AFBD9EA.4040907@free.fr> <68762EC9-30F8-4594-BBE3-095C3B44A7A9@gmail.com> <4AFC61AC.8080806@free.fr> <291C756E-2006-4E03-B4B7-150136242E11@gmail.com> <0FE16449-8429-4D18-8E7D-545DBD67CFE1@apple.com> Message-ID: <4AFD341A.60106@free.fr> Hi Dan, >>> A call can be "nounwind" without the >>> callee necessarily being nounwind. Your patch only catches the case of the >>> callee being nounwind. The CallSite doesNotThrow method checks for both of >>> these possibilities. I think what should happen is: at the moment of lowering >>> the IR to SDAG nodes, check "doesNotThrow" on calls and set a corresponding >>> flag in the SDAG node. Check this flag when outputting the dwarf table. >> Possible. Though at the point of DWARF generation, we don't have the SDAG nodes anymore. So it would have to be propagated to the CALL instruction. > > Crazy idea: would it make sense to extend MachineMemOperand > to be able to describe which Function is being called in > a call MachineInstr? thanks for thinking about this. Unfortunately that doesn't handle the case of a call that is marked nounwind, to a callee that is not marked nounwind. Ciao, Duncan. From rdivacky at freebsd.org Fri Nov 13 05:48:04 2009 From: rdivacky at freebsd.org (Roman Divacky) Date: Fri, 13 Nov 2009 12:48:04 +0100 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem Message-ID: <20091113114804.GA34165@freebsd.org> hi the attached patch moves cpu detection code from lib/Target/$FOO (for FOO=X86 :) ) to lib/System. This is necessary for clang to be able to do -march=native. The patch was already reviewed by Daniel Dunbar. Can you please review/commit this? thnx! roman p.s. CC: me as I am not subscribed to llvm-commits -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-march=native.patch Type: text/x-diff Size: 10733 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091113/45ffde5a/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091113/45ffde5a/attachment-0001.bin From dag at cray.com Fri Nov 13 08:37:36 2009 From: dag at cray.com (David Greene) Date: Fri, 13 Nov 2009 08:37:36 -0600 Subject: [llvm-commits] [llvm] r87022 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ In-Reply-To: References: <200911122049.nACKnPDw008707@zion.cs.uiuc.edu> Message-ID: <200911130837.36609.dag@cray.com> On Thursday 12 November 2009 19:00, you wrote: > Why is this necessary? As of 84326 each StackObject already has a > isSpillSlot bool field. Probably a collision with another revision. Will fix. -Dave From greened at obbligato.org Fri Nov 13 08:42:06 2009 From: greened at obbligato.org (David Greene) Date: Fri, 13 Nov 2009 14:42:06 -0000 Subject: [llvm-commits] [llvm] r87106 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <200911131442.nADEg6nY005653@zion.cs.uiuc.edu> Author: greened Date: Fri Nov 13 08:42:06 2009 New Revision: 87106 URL: http://llvm.org/viewvc/llvm-project?rev=87106&view=rev Log: Remove duplicate APIs and state WRT spill objects. Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=87106&r1=87105&r2=87106&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Nov 13 08:42:06 2009 @@ -389,9 +389,6 @@ Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); int Index = (int)Objects.size()-NumFixedObjects-1; assert(Index >= 0 && "Bad frame index!"); - if (SpillObjects.size() <= static_cast(Index)) - SpillObjects.resize(Index+1); - SpillObjects[Index] = false; return Index; } @@ -402,9 +399,6 @@ int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { CreateStackObject(Size, Alignment, true); int Index = (int)Objects.size()-NumFixedObjects-1; - if (SpillObjects.size() <= static_cast(Index)) - SpillObjects.resize(Index+1); - SpillObjects[Index] = true; return Index; } @@ -426,16 +420,6 @@ return (int)Objects.size()-NumFixedObjects-1; } - /// isSpillObject - Return whether the index refers to a spill slot. - /// - bool isSpillObject(int Index) const { - // Negative indices can't be spill slots. - if (Index < 0) return false; - assert(static_cast(Index) < SpillObjects.size() && - "Invalid frame index!"); - return SpillObjects[Index]; - } - /// getCalleeSavedInfo - Returns a reference to call saved info vector for the /// current function. const std::vector &getCalleeSavedInfo() const { From vhernandez at apple.com Fri Nov 13 10:41:58 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 13 Nov 2009 08:41:58 -0800 Subject: [llvm-commits] [llvm] r87059 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp In-Reply-To: <352a1fb20911121823s1ab58f60gfd896646b64d1ee5@mail.gmail.com> References: <200911130144.nAD1itY1028121@zion.cs.uiuc.edu> <352a1fb20911121823s1ab58f60gfd896646b64d1ee5@mail.gmail.com> Message-ID: <392FAB19-9594-4895-8199-47AE9CA0CF8D@apple.com> Thanks Devang. Those tests did not fail on my system, so I need to investigate what misconfiguration I have going on. Victor On Nov 12, 2009, at 6:23 PM, Devang Patel wrote: > Victor, > > On Thu, Nov 12, 2009 at 5:44 PM, Victor Hernandez wrote: >> Author: hernande >> Date: Thu Nov 12 19:44:55 2009 >> New Revision: 87059 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=87059&view=rev >> Log: >> Remove unnecessary llvm.dbg.declare bitcast > > This is failing following clang tests. I am reverting this for now. > > Failing Tests (9): > Clang::CodeGen/2009-01-21-invalid-debug-info.m > Clang::CodeGen/2009-07-31-DbgDeclare.c > Clang::CodeGen/debug-info.c > Clang::CodeGen/vector.c > Clang::CodeGenCXX/PR4890-debug-info-dtor.cpp > Clang::CodeGenObjC/debug-info-linkagename.m > Clang::CodeGenObjC/objc2-weak-ivar-debug.m > Clang::Coverage/codegen-next.m > Clang::Coverage/codegen.c > - > Devang From criswell at cs.uiuc.edu Fri Nov 13 11:13:48 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 13 Nov 2009 11:13:48 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/downloads.html Message-ID: <200911131713.nADHDm1t029567@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: downloads.html added (r1.1) --- Log message: Adding SAFECode download page. --- Diffs of the changes: (+94 -0) downloads.html | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 94 insertions(+) Index: llvm-www/safecode/downloads.html diff -c /dev/null llvm-www/safecode/downloads.html:1.1 *** /dev/null Fri Nov 13 11:13:06 2009 --- llvm-www/safecode/downloads.html Fri Nov 13 11:12:56 2009 *************** *** 0 **** --- 1,94 ---- + + + + + + + + + + + + + + + + SAFECode: Downloads + + + + + +
    + + + + +
    + + + +
    + +
    + +

    Home

    +
    + +

    + SAFECode is available from the LLVM SVN repository. You can download + it using the following command: +

    + +

    + svn co http://llvm.org/svn/llvm-project/safecode/trunk safecode +

    + +

    + Directions on compiling and using SAFECode can be found in the + safecode/docs directory in the source code. +

    +
    +
    + +
    + +
    + + +
    + + + + + + + From criswell at cs.uiuc.edu Fri Nov 13 11:15:12 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 13 Nov 2009 11:15:12 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/sidebar.incl Message-ID: <200911131715.nADHFCAJ029620@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: sidebar.incl updated: 1.1 -> 1.2 --- Log message: Added Downloads link. --- Diffs of the changes: (+1 -0) sidebar.incl | 1 + 1 files changed, 1 insertion(+) Index: llvm-www/safecode/sidebar.incl diff -u llvm-www/safecode/sidebar.incl:1.1 llvm-www/safecode/sidebar.incl:1.2 --- llvm-www/safecode/sidebar.incl:1.1 Tue Nov 3 09:36:52 2009 +++ llvm-www/safecode/sidebar.incl Fri Nov 13 11:14:30 2009 @@ -2,6 +2,7 @@

    Menu

    • Home
    • +
    • Downloads
    • Publications
    • Project Members
    • Links
    • From criswell at cs.uiuc.edu Fri Nov 13 11:17:15 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 13 Nov 2009 11:17:15 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/downloads.html Message-ID: <200911131717.nADHHFjN029684@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: downloads.html updated: 1.1 -> 1.2 --- Log message: Fixed header text. --- Diffs of the changes: (+1 -1) downloads.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/safecode/downloads.html diff -u llvm-www/safecode/downloads.html:1.1 llvm-www/safecode/downloads.html:1.2 --- llvm-www/safecode/downloads.html:1.1 Fri Nov 13 11:12:56 2009 +++ llvm-www/safecode/downloads.html Fri Nov 13 11:16:32 2009 @@ -44,7 +44,7 @@
      -

      Home

      +

      Downloading From the Subversion Repository


      From baldrick at free.fr Fri Nov 13 11:58:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 17:58:12 -0000 Subject: [llvm-commits] [dragonegg] r88664 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200911131758.nADHwDTF013582@zion.cs.uiuc.edu> Author: baldrick Date: Fri Nov 13 11:58:09 2009 New Revision: 88664 URL: http://llvm.org/viewvc/llvm-project?rev=88664&view=rev Log: Port revisions 85265, 85466, 85477, 86371 and 86487 from llvm-gcc: implementing BUILT_IN_OBJECT_SIZE. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88664&r1=88663&r2=88664&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Nov 13 11:58:09 2009 @@ -4448,17 +4448,18 @@ Emit(gimple_call_arg(stmt, 1), 0) }; - const Type* Ty[3] = { - ConvertType(gimple_call_return_type(stmt)), - Type::getInt8PtrTy(Context), - Type::getInt32Ty(Context) - }; + // Grab the current return type. + const Type* Ty = ConvertType(gimple_call_return_type(stmt)); + + // Manually coerce the arg to the correct pointer type. + Args[0] = Builder.CreateBitCast(Args[0], Type::getInt8PtrTy(Context)); + Args[1] = Builder.CreateIntCast(Args[1], Type::getInt32Ty(Context), false); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::objectsize, - Ty, - 1), - Args, Args + 2); + Intrinsic::objectsize, + &Ty, + 1), + Args, Args + 2); return true; } // Unary bit counting intrinsics. From baldrick at free.fr Fri Nov 13 12:02:40 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 18:02:40 -0000 Subject: [llvm-commits] [dragonegg] r88665 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200911131802.nADI2epl013754@zion.cs.uiuc.edu> Author: baldrick Date: Fri Nov 13 12:02:39 2009 New Revision: 88665 URL: http://llvm.org/viewvc/llvm-project?rev=88665&view=rev Log: Port commit 85284 (johannes) from llvm-gcc: We already had a hack to do this: // G++ has various bugs handling {} initializers where it doesn't // synthesize a zero node of the right type. Instead of figuring out G++, // just hack around it by special casing zero and allowing it to be the // wrong size. but the handling was limited to bitfields. It turns out this can happen with non-bitfields as well; extend it to cover that case. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88665&r1=88664&r2=88665&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Nov 13 12:02:39 2009 @@ -7866,6 +7866,23 @@ uint64_t GCCFieldOffsetInBits = getFieldOffsetInBits(Field); NextField = TREE_CHAIN(Field); + uint64_t FieldSizeInBits = getInt64(DECL_SIZE(Field), true); + uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits(); + ConstantInt *ValC = dyn_cast(Val); + if (ValC && ValC->isZero()) { + // G++ has various bugs handling {} initializers where it doesn't + // synthesize a zero node of the right type. Instead of figuring out G++, + // just hack around it by special casing zero and allowing it to be the + // wrong size. + if (ValueSizeInBits != FieldSizeInBits) { + APInt ValAsInt = ValC->getValue(); + ValC = ConstantInt::get(Context, ValueSizeInBits < FieldSizeInBits ? + ValAsInt.zext(FieldSizeInBits) : + ValAsInt.trunc(FieldSizeInBits)); + ValueSizeInBits = FieldSizeInBits; + Val = ValC; + } + } // If this is a non-bitfield value, just slap it onto the end of the struct // with the appropriate padding etc. If it is a bitfield, we have more @@ -7875,20 +7892,7 @@ else { // Bitfields can only be initialized with constants (integer constant // expressions). - ConstantInt *ValC = cast(Val); - uint64_t FieldSizeInBits = getInt64(DECL_SIZE(Field), true); - uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits(); - - // G++ has various bugs handling {} initializers where it doesn't - // synthesize a zero node of the right type. Instead of figuring out G++, - // just hack around it by special casing zero and allowing it to be the - // wrong size. - if (ValueSizeInBits < FieldSizeInBits && ValC->isZero()) { - APInt ValAsInt = ValC->getValue(); - ValC = ConstantInt::get(Context, ValAsInt.zext(FieldSizeInBits)); - ValueSizeInBits = FieldSizeInBits; - } - + assert(ValC); assert(ValueSizeInBits >= FieldSizeInBits && "disagreement between LLVM and GCC on bitfield size"); if (ValueSizeInBits != FieldSizeInBits) { From baldrick at free.fr Fri Nov 13 12:04:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 Nov 2009 18:04:58 -0000 Subject: [llvm-commits] [dragonegg] r88666 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200911131804.nADI4x5l013853@zion.cs.uiuc.edu> Author: baldrick Date: Fri Nov 13 12:04:58 2009 New Revision: 88666 URL: http://llvm.org/viewvc/llvm-project?rev=88666&view=rev Log: Port commits 85303 and 85407 (johannes) from llvm-gcc: Make previous change not crash when size of object is unknown. Remove used-uninitialized warning. Add an assert to make it clearer to humans there is no uninitialized use, but there's no way a compiler could figure it out. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88666&r1=88665&r2=88666&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Nov 13 12:04:58 2009 @@ -7866,10 +7866,12 @@ uint64_t GCCFieldOffsetInBits = getFieldOffsetInBits(Field); NextField = TREE_CHAIN(Field); - uint64_t FieldSizeInBits = getInt64(DECL_SIZE(Field), true); + uint64_t FieldSizeInBits = 0; + if (DECL_SIZE(Field)) + FieldSizeInBits = getInt64(DECL_SIZE(Field), true); uint64_t ValueSizeInBits = Val->getType()->getPrimitiveSizeInBits(); ConstantInt *ValC = dyn_cast(Val); - if (ValC && ValC->isZero()) { + if (ValC && ValC->isZero() && DECL_SIZE(Field)) { // G++ has various bugs handling {} initializers where it doesn't // synthesize a zero node of the right type. Instead of figuring out G++, // just hack around it by special casing zero and allowing it to be the @@ -7893,6 +7895,7 @@ // Bitfields can only be initialized with constants (integer constant // expressions). assert(ValC); + assert(DECL_SIZE(Field)); assert(ValueSizeInBits >= FieldSizeInBits && "disagreement between LLVM and GCC on bitfield size"); if (ValueSizeInBits != FieldSizeInBits) { From evan.cheng at apple.com Fri Nov 13 12:49:01 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 13 Nov 2009 10:49:01 -0800 Subject: [llvm-commits] [llvm] r87106 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h In-Reply-To: <200911131442.nADEg6nY005653@zion.cs.uiuc.edu> References: <200911131442.nADEg6nY005653@zion.cs.uiuc.edu> Message-ID: <1F64F209-8649-4490-B5F7-6F557A5097CD@apple.com> Thanks. Evan On Nov 13, 2009, at 6:42 AM, David Greene wrote: > Author: greened > Date: Fri Nov 13 08:42:06 2009 > New Revision: 87106 > > URL: http://llvm.org/viewvc/llvm-project?rev=87106&view=rev > Log: > > Remove duplicate APIs and state WRT spill objects. > > Modified: > llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h > > Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=87106&r1=87105&r2=87106&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Nov 13 > 08:42:06 2009 > @@ -389,9 +389,6 @@ > Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); > int Index = (int)Objects.size()-NumFixedObjects-1; > assert(Index >= 0 && "Bad frame index!"); > - if (SpillObjects.size() <= static_cast(Index)) > - SpillObjects.resize(Index+1); > - SpillObjects[Index] = false; > return Index; > } > > @@ -402,9 +399,6 @@ > int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { > CreateStackObject(Size, Alignment, true); > int Index = (int)Objects.size()-NumFixedObjects-1; > - if (SpillObjects.size() <= static_cast(Index)) > - SpillObjects.resize(Index+1); > - SpillObjects[Index] = true; > return Index; > } > > @@ -426,16 +420,6 @@ > return (int)Objects.size()-NumFixedObjects-1; > } > > - /// isSpillObject - Return whether the index refers to a spill > slot. > - /// > - bool isSpillObject(int Index) const { > - // Negative indices can't be spill slots. > - if (Index < 0) return false; > - assert(static_cast(Index) < SpillObjects.size() && > - "Invalid frame index!"); > - return SpillObjects[Index]; > - } > - > /// getCalleeSavedInfo - Returns a reference to call saved info > vector for the > /// current function. > const std::vector &getCalleeSavedInfo() const { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Fri Nov 13 12:49:38 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Nov 2009 18:49:38 -0000 Subject: [llvm-commits] [llvm] r88672 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp test/CodeGen/X86/tailcall1.ll Message-ID: <200911131849.nADIncoh015346@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 12:49:38 2009 New Revision: 88672 URL: http://llvm.org/viewvc/llvm-project?rev=88672&view=rev Log: Don't let a noalias difference disrupt the tailcall optimization. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/test/CodeGen/X86/tailcall1.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=88672&r1=88671&r2=88672&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Nov 13 12:49:38 2009 @@ -4349,7 +4349,7 @@ /// TargetLowering::IsEligibleForTailCallOptimization. /// static bool -isInTailCallPosition(const Instruction *I, Attributes RetAttr, +isInTailCallPosition(const Instruction *I, Attributes CalleeRetAttr, const TargetLowering &TLI) { const BasicBlock *ExitBB = I->getParent(); const TerminatorInst *Term = ExitBB->getTerminator(); @@ -4377,8 +4377,9 @@ if (!Ret || Ret->getNumOperands() == 0) return true; // Conservatively require the attributes of the call to match those of - // the return. - if (F->getAttributes().getRetAttributes() != RetAttr) + // the return. Ignore noalias because it doesn't affect the call sequence. + unsigned CallerRetAttr = F->getAttributes().getRetAttributes(); + if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias) return false; // Otherwise, make sure the unmodified return value of I is the return value. Modified: llvm/trunk/test/CodeGen/X86/tailcall1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tailcall1.ll?rev=88672&r1=88671&r2=88672&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tailcall1.ll (original) +++ llvm/trunk/test/CodeGen/X86/tailcall1.ll Fri Nov 13 12:49:38 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -tailcallopt | grep TAILCALL +; RUN: llc < %s -march=x86 -tailcallopt | grep TAILCALL | count 3 define fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { entry: ret i32 %a3 @@ -9,3 +9,17 @@ %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] ret i32 %tmp11 } + +declare fastcc i8* @alias_callee() + +define fastcc noalias i8* @noalias_caller() nounwind { + %p = tail call fastcc i8* @alias_callee() + ret i8* %p +} + +declare fastcc noalias i8* @noalias_callee() + +define fastcc i8* @alias_caller() nounwind { + %p = tail call fastcc noalias i8* @noalias_callee() + ret i8* %p +} From bruno.cardoso at gmail.com Fri Nov 13 12:49:59 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Fri, 13 Nov 2009 18:49:59 -0000 Subject: [llvm-commits] [llvm] r88674 - in /llvm/trunk/lib/Target/Mips: MipsISelDAGToDAG.cpp MipsInstrInfo.cpp Message-ID: <200911131849.nADInxvY015378@zion.cs.uiuc.edu> Author: bruno Date: Fri Nov 13 12:49:59 2009 New Revision: 88674 URL: http://llvm.org/viewvc/llvm-project?rev=88674&view=rev Log: Support fp64 immediate zero, this fixes only part of PR5445 because the testcase is triggering one more bug. Modified: llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Modified: llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp?rev=88674&r1=88673&r2=88674&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp Fri Nov 13 12:49:59 2009 @@ -314,6 +314,16 @@ case ISD::GLOBAL_OFFSET_TABLE: return getGlobalBaseReg(); + case ISD::ConstantFP: { + ConstantFPSDNode *CN = dyn_cast(N); + if (N.getValueType() == MVT::f64 && CN->isExactlyValue(+0.0)) { + SDValue Zero = CurDAG->getRegister(Mips::ZERO, MVT::i32); + ReplaceUses(N, Zero); + return Zero.getNode(); + } + break; + } + /// Handle direct and indirect calls when using PIC. On PIC, when /// GOT is smaller than about 64k (small code) the GA target is /// loaded with only one instruction. Otherwise GA's target must Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp?rev=88674&r1=88673&r2=88674&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Fri Nov 13 12:49:59 2009 @@ -134,6 +134,9 @@ const TargetRegisterClass *DestRC, const TargetRegisterClass *SrcRC) const { DebugLoc DL = DebugLoc::getUnknownLoc(); + const MachineFunction *MF = MBB.getParent(); + const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo(); + if (I != MBB.end()) DL = I->getDebugLoc(); if (DestRC != SrcRC) { @@ -153,6 +156,13 @@ else if ((DestRC == Mips::FGR32RegisterClass) && (SrcRC == Mips::CPURegsRegisterClass)) BuildMI(MBB, I, DL, get(Mips::MTC1), DestReg).addReg(SrcReg); + else if ((DestRC == Mips::AFGR64RegisterClass) && + (SrcRC == Mips::CPURegsRegisterClass) && + (SrcReg == Mips::ZERO)) { + const unsigned *AliasSet = TRI->getAliasSet(DestReg); + BuildMI(MBB, I, DL, get(Mips::MTC1), AliasSet[0]).addReg(SrcReg); + BuildMI(MBB, I, DL, get(Mips::MTC1), AliasSet[1]).addReg(SrcReg); + } // Move from/to Hi/Lo registers else if ((DestRC == Mips::HILORegisterClass) && @@ -163,9 +173,8 @@ (DestRC == Mips::CPURegsRegisterClass)) { unsigned Opc = (SrcReg == Mips::HI) ? Mips::MFHI : Mips::MFLO; BuildMI(MBB, I, DL, get(Opc), DestReg); - - // Can't copy this register - } else + } else + // Can't copy this register return false; return true; From gohman at apple.com Fri Nov 13 12:58:04 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Nov 2009 10:58:04 -0800 Subject: [llvm-commits] [llvm] r86871 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/MachineBasicBlock.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/Thumb2/thumb2-ifcvt3.ll test/CodeGen/X86/loop-blocks.ll test/CodeGen/X86/tail-opts.ll In-Reply-To: <6E45DF35-172E-409D-8D71-4724ED17BD31@apple.com> References: <200911111949.nABJn0tU002696@zion.cs.uiuc.edu> <4AFBBC6B.8010304@free.fr> <8AF3B4D7-752E-4DD9-81FF-30C8A6F4F4C0@apple.com> <6E45DF35-172E-409D-8D71-4724ED17BD31@apple.com> Message-ID: On Nov 12, 2009, at 1:54 PM, Chris Lattner wrote: > > On Nov 12, 2009, at 10:39 AM, Dan Gohman wrote: > >> >> On Nov 11, 2009, at 11:42 PM, Duncan Sands wrote: >> >>> Hi Dan, >>> >>>> Add support for tail duplication to BranchFolding, and extend >>>> tail merging support to handle more cases. >>>> - Recognize several cases where tail merging is beneficial even when >>>> the tail size is smaller than the generic threshold. >>>> - Make use of MachineInstrDesc::isBarrier to help detect >>>> non-fallthrough blocks. >>>> - Check for and avoid disrupting fall-through edges in more cases. >>> >>> can this result in a label being sucked off the end of a block, and >>> moved into another? Exception handling labels come in pairs, and it >>> would be wrong to move one of them without the other (even all the >>> instructions in between). >> >> My understanding is that each EH_LABEL has a unique ID, and this >> automatically prevents two of them from being merged. >> >> I just made a change to mark all label instructions as non-duplicable, >> to prevent tail-duplication and other code-duplicating optimizations >> from getting into trouble. > > Does this cause debug labels to change optimization/codegen behavior? Hrm yes. I'll look into this. Dan From isanbard at gmail.com Fri Nov 13 13:31:26 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 13 Nov 2009 11:31:26 -0800 Subject: [llvm-commits] [llvm] r87023 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp In-Reply-To: <4AFD312A.2010100@free.fr> References: <200911122051.nACKps7d008820@zion.cs.uiuc.edu> <4AFD312A.2010100@free.fr> Message-ID: <4EC4C39C-6BC0-4C98-BE8F-C5AF148B43EA@gmail.com> On Nov 13, 2009, at 2:12 AM, Duncan Sands wrote: > Hi Bill, > >> If there's more than one function operand to a call instruction, be >> conservative >> and don't assume that the call doesn't throw. It would be nice if >> there were a >> way to determine which is the callee and which is a parameter. In >> practice, the >> architecture we care about normally only have one operand for a >> call instruction >> (x86 and arm). > > good idea! Pity this is still not philosophically correct, i.e. > does not handle > the case of a nounwind call to a function that is not marked > nounwind... > I talked with Dan about his proposal to put this information in a MachineMemOperand. It sounds like a good idea, but is more work than this. I'll investigate that. -bw From david_goodwin at apple.com Fri Nov 13 13:52:48 2009 From: david_goodwin at apple.com (David Goodwin) Date: Fri, 13 Nov 2009 19:52:48 -0000 Subject: [llvm-commits] [llvm] r88682 - in /llvm/trunk: include/llvm/Target/TargetSubtarget.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/TargetSubtarget.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h Message-ID: <200911131952.nADJqnkW017947@zion.cs.uiuc.edu> Author: david_goodwin Date: Fri Nov 13 13:52:48 2009 New Revision: 88682 URL: http://llvm.org/viewvc/llvm-project?rev=88682&view=rev Log: Allow target to specify regclass for which antideps will only be broken along the critical path. Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/TargetSubtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSubtarget.h?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSubtarget.h (original) +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Fri Nov 13 13:52:48 2009 @@ -38,7 +38,7 @@ // AntiDepBreakMode - Type of anti-dependence breaking that should // be performed before post-RA scheduling. typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode; - typedef SmallVectorImpl ExcludedRCVector; + typedef SmallVectorImpl RegClassVector; virtual ~TargetSubtarget(); @@ -50,10 +50,12 @@ // enablePostRAScheduler - If the target can benefit from post-regalloc // scheduling and the specified optimization level meets the requirement - // return true to enable post-register-allocation scheduling. + // return true to enable post-register-allocation scheduling. In + // CriticalPathRCs return any register classes that should only be broken + // if on the critical path. virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const; + RegClassVector& CriticalPathRCs) const; // adjustSchedDependency - Perform target specific adjustments to // the latency of a schedule dependency. virtual void adjustSchedDependency(SUnit *def, SUnit *use, Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Fri Nov 13 13:52:48 2009 @@ -54,10 +54,13 @@ return Node; } -void AggressiveAntiDepState::GetGroupRegs(unsigned Group, std::vector &Regs) +void AggressiveAntiDepState::GetGroupRegs( + unsigned Group, + std::vector &Regs, + std::multimap *RegRefs) { for (unsigned Reg = 0; Reg != TargetRegisterInfo::FirstVirtualRegister; ++Reg) { - if (GetGroup(Reg) == Group) + if ((GetGroup(Reg) == Group) && (RegRefs->count(Reg) > 0)) Regs.push_back(Reg); } } @@ -100,23 +103,27 @@ AggressiveAntiDepBreaker:: AggressiveAntiDepBreaker(MachineFunction& MFi, - TargetSubtarget::ExcludedRCVector& ExcludedRCs) : + TargetSubtarget::RegClassVector& CriticalPathRCs) : AntiDepBreaker(), MF(MFi), MRI(MF.getRegInfo()), TRI(MF.getTarget().getRegisterInfo()), AllocatableSet(TRI->getAllocatableSet(MF)), State(NULL), SavedState(NULL) { - /* Remove all registers from excluded RCs from the allocatable - register set. */ - for (unsigned i = 0, e = ExcludedRCs.size(); i < e; ++i) { - BitVector NotRenameable = TRI->getAllocatableSet(MF, ExcludedRCs[i]).flip(); - AllocatableSet &= NotRenameable; - } - - DEBUG(errs() << "AntiDep Renameable Registers:"); - DEBUG(for (int r = AllocatableSet.find_first(); r != -1; - r = AllocatableSet.find_next(r)) + /* Collect a bitset of all registers that are only broken if they + are on the critical path. */ + for (unsigned i = 0, e = CriticalPathRCs.size(); i < e; ++i) { + BitVector CPSet = TRI->getAllocatableSet(MF, CriticalPathRCs[i]); + if (CriticalPathSet.none()) + CriticalPathSet = CPSet; + else + CriticalPathSet |= CPSet; + } + + DEBUG(errs() << "AntiDep Critical-Path Registers:"); + DEBUG(for (int r = CriticalPathSet.find_first(); r != -1; + r = CriticalPathSet.find_next(r)) errs() << " " << TRI->getName(r)); + DEBUG(errs() << '\n'); } AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() { @@ -276,9 +283,11 @@ } } -/// AntiDepPathStep - Return SUnit that SU has an anti-dependence on. -static void AntiDepPathStep(SUnit *SU, AntiDepBreaker::AntiDepRegVector& Regs, - std::vector& Edges) { +/// AntiDepEdges - Return in Edges the anti- and output- +/// dependencies on Regs in SU that we want to consider for breaking. +static void AntiDepEdges(SUnit *SU, + const AntiDepBreaker::AntiDepRegVector& Regs, + std::vector& Edges) { AntiDepBreaker::AntiDepRegSet RegSet; for (unsigned i = 0, e = Regs.size(); i < e; ++i) RegSet.insert(Regs[i]); @@ -297,6 +306,31 @@ assert(RegSet.empty() && "Expected all antidep registers to be found"); } +/// CriticalPathStep - Return the next SUnit after SU on the bottom-up +/// critical path. +static SUnit *CriticalPathStep(SUnit *SU) { + SDep *Next = 0; + unsigned NextDepth = 0; + // Find the predecessor edge with the greatest depth. + if (SU != 0) { + for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end(); + P != PE; ++P) { + SUnit *PredSU = P->getSUnit(); + unsigned PredLatency = P->getLatency(); + unsigned PredTotalLatency = PredSU->getDepth() + PredLatency; + // In the case of a latency tie, prefer an anti-dependency edge over + // other types of edges. + if (NextDepth < PredTotalLatency || + (NextDepth == PredTotalLatency && P->getKind() == SDep::Anti)) { + NextDepth = PredTotalLatency; + Next = &*P; + } + } + } + + return (Next) ? Next->getSUnit() : 0; +} + void AggressiveAntiDepBreaker::HandleLastUse(unsigned Reg, unsigned KillIdx, const char *tag) { unsigned *KillIndices = State->GetKillIndices(); @@ -511,11 +545,11 @@ std::multimap& RegRefs = State->GetRegRefs(); - // Collect all registers in the same group as AntiDepReg. These all - // need to be renamed together if we are to break the - // anti-dependence. + // Collect all referenced registers in the same group as + // AntiDepReg. These all need to be renamed together if we are to + // break the anti-dependence. std::vector Regs; - State->GetGroupRegs(AntiDepGroupIndex, Regs); + State->GetGroupRegs(AntiDepGroupIndex, Regs, &RegRefs); assert(Regs.size() > 0 && "Empty register group!"); if (Regs.size() == 0) return false; @@ -556,9 +590,10 @@ } // FIXME: for now just handle single register in group case... - // FIXME: check only regs that have references... - if (Regs.size() > 1) + if (Regs.size() > 1) { + DEBUG(errs() << "\tMultiple rename registers in group\n"); return false; + } // Check each possible rename register for SuperReg in round-robin // order. If that register is available, and the corresponding @@ -666,6 +701,24 @@ MISUnitMap.insert(std::pair(SU->getInstr(), SU)); } + // Track progress along the critical path through the SUnit graph as + // we walk the instructions. This is needed for regclasses that only + // break critical-path anti-dependencies. + SUnit *CriticalPathSU = 0; + MachineInstr *CriticalPathMI = 0; + if (CriticalPathSet.any()) { + for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { + SUnit *SU = &SUnits[i]; + if (!CriticalPathSU || + ((SU->getDepth() + SU->Latency) > + (CriticalPathSU->getDepth() + CriticalPathSU->Latency))) { + CriticalPathSU = SU; + } + } + + CriticalPathMI = CriticalPathSU->getInstr(); + } + // Even if there are no anti-dependencies we still need to go // through the instructions to update Def, Kills, etc. #ifndef NDEBUG @@ -700,14 +753,26 @@ // Process the defs in MI... PrescanInstruction(MI, Count, PassthruRegs); - + + // The the dependence edges that represent anti- and output- + // dependencies that are candidates for breaking. std::vector Edges; SUnit *PathSU = MISUnitMap[MI]; AntiDepBreaker::CandidateMap::iterator citer = Candidates.find(PathSU); if (citer != Candidates.end()) - AntiDepPathStep(PathSU, citer->second, Edges); - + AntiDepEdges(PathSU, citer->second, Edges); + + // If MI is not on the critical path, then we don't rename + // registers in the CriticalPathSet. + BitVector *ExcludeRegs = NULL; + if (MI == CriticalPathMI) { + CriticalPathSU = CriticalPathStep(CriticalPathSU); + CriticalPathMI = (CriticalPathSU) ? CriticalPathSU->getInstr() : 0; + } else { + ExcludeRegs = &CriticalPathSet; + } + // Ignore KILL instructions (they form a group in ScanInstruction // but don't cause any anti-dependence breaking themselves) if (MI->getOpcode() != TargetInstrInfo::KILL) { @@ -727,6 +792,11 @@ // Don't break anti-dependencies on non-allocatable registers. DEBUG(errs() << " (non-allocatable)\n"); continue; + } else if ((ExcludeRegs != NULL) && ExcludeRegs->test(AntiDepReg)) { + // Don't break anti-dependencies for critical path registers + // if not on the critical path + DEBUG(errs() << " (not critical-path)\n"); + continue; } else if (PassthruRegs.count(AntiDepReg) != 0) { // If the anti-dep register liveness "passes-thru", then // don't try to change it. It will be changed along with Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Fri Nov 13 13:52:48 2009 @@ -86,8 +86,11 @@ unsigned GetGroup(unsigned Reg); // GetGroupRegs - Return a vector of the registers belonging to a - // group. - void GetGroupRegs(unsigned Group, std::vector &Regs); + // group. If RegRefs is non-NULL then only included referenced registers. + void GetGroupRegs( + unsigned Group, + std::vector &Regs, + std::multimap *RegRefs); // UnionGroups - Union Reg1's and Reg2's groups to form a new // group. Return the index of the GroupNode representing the @@ -113,7 +116,11 @@ /// AllocatableSet - The set of allocatable registers. /// We'll be ignoring anti-dependencies on non-allocatable registers, /// because they may not be safe to break. - BitVector AllocatableSet; + const BitVector AllocatableSet; + + /// CriticalPathSet - The set of registers that should only be + /// renamed if they are on the critical path. + BitVector CriticalPathSet; /// State - The state used to identify and rename anti-dependence /// registers. @@ -126,7 +133,7 @@ public: AggressiveAntiDepBreaker(MachineFunction& MFi, - TargetSubtarget::ExcludedRCVector& ExcludedRCs); + TargetSubtarget::RegClassVector& CriticalPathRCs); ~AggressiveAntiDepBreaker(); /// GetMaxTrials - As anti-dependencies are broken, additional Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Fri Nov 13 13:52:48 2009 @@ -216,14 +216,14 @@ // Check for explicit enable/disable of post-ra scheduling. TargetSubtarget::AntiDepBreakMode AntiDepMode = TargetSubtarget::ANTIDEP_NONE; - SmallVector ExcludedRCs; + SmallVector CriticalPathRCs; if (EnablePostRAScheduler.getPosition() > 0) { if (!EnablePostRAScheduler) return false; } else { // Check that post-RA scheduling is enabled for this target. const TargetSubtarget &ST = Fn.getTarget().getSubtarget(); - if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, ExcludedRCs)) + if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, CriticalPathRCs)) return false; } @@ -244,7 +244,7 @@ (ScheduleHazardRecognizer *)new SimpleHazardRecognizer(); AntiDepBreaker *ADB = ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ? - (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, ExcludedRCs) : + (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, CriticalPathRCs) : ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ? (AntiDepBreaker *)new CriticalAntiDepBreaker(Fn) : NULL)); Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Nov 13 13:52:48 2009 @@ -164,9 +164,9 @@ bool ARMSubtarget::enablePostRAScheduler( CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { + RegClassVector& CriticalPathRCs) const { Mode = TargetSubtarget::ANTIDEP_CRITICAL; - ExcludedRCs.clear(); - ExcludedRCs.push_back(&ARM::GPRRegClass); + CriticalPathRCs.clear(); + CriticalPathRCs.push_back(&ARM::GPRRegClass); return PostRAScheduler && OptLevel >= CodeGenOpt::Default; } Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Fri Nov 13 13:52:48 2009 @@ -130,7 +130,7 @@ /// enablePostRAScheduler - True at 'More' optimization. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const; + RegClassVector& CriticalPathRCs) const; /// getInstrItins - Return the instruction itineraies based on subtarget /// selection. Modified: llvm/trunk/lib/Target/TargetSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetSubtarget.cpp?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetSubtarget.cpp (original) +++ llvm/trunk/lib/Target/TargetSubtarget.cpp Fri Nov 13 13:52:48 2009 @@ -25,9 +25,9 @@ bool TargetSubtarget::enablePostRAScheduler( CodeGenOpt::Level OptLevel, AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { + RegClassVector& CriticalPathRCs) const { Mode = ANTIDEP_NONE; - ExcludedRCs.clear(); + CriticalPathRCs.clear(); return false; } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Fri Nov 13 13:52:48 2009 @@ -460,8 +460,8 @@ bool X86Subtarget::enablePostRAScheduler( CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const { + RegClassVector& CriticalPathRCs) const { Mode = TargetSubtarget::ANTIDEP_CRITICAL; - ExcludedRCs.clear(); + CriticalPathRCs.clear(); return OptLevel >= CodeGenOpt::Default; } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=88682&r1=88681&r2=88682&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Fri Nov 13 13:52:48 2009 @@ -220,7 +220,7 @@ /// at 'More' optimization level. bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, TargetSubtarget::AntiDepBreakMode& Mode, - ExcludedRCVector& ExcludedRCs) const; + RegClassVector& CriticalPathRCs) const; }; } // End llvm namespace From evan.cheng at apple.com Fri Nov 13 14:36:40 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 13 Nov 2009 20:36:40 -0000 Subject: [llvm-commits] [llvm] r88690 - in /llvm/trunk: lib/CodeGen/LiveVariables.cpp test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll Message-ID: <200911132036.nADKaeBa019547@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 14:36:40 2009 New Revision: 88690 URL: http://llvm.org/viewvc/llvm-project?rev=88690&view=rev Log: Fix PR5410: LiveVariables lost subreg def: D0 = ... .. = S0 S0 = ... .. D0 = The first D0 def is correctly marked dead, however, livevariables should have added an implicit def of S0 or we end up with a use without a def. Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=88690&r1=88689&r2=88690&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Fri Nov 13 14:36:40 2009 @@ -230,8 +230,9 @@ /// implicit defs to a machine instruction if there was an earlier def of its /// super-register. void LiveVariables::HandlePhysRegUse(unsigned Reg, MachineInstr *MI) { + MachineInstr *LastDef = PhysRegDef[Reg]; // If there was a previous use or a "full" def all is well. - if (!PhysRegDef[Reg] && !PhysRegUse[Reg]) { + if (!LastDef && !PhysRegUse[Reg]) { // Otherwise, the last sub-register def implicitly defines this register. // e.g. // AH = @@ -265,6 +266,11 @@ } } } + else if (LastDef && !PhysRegUse[Reg] && + !LastDef->findRegisterDefOperand(Reg)) + // Last def defines the super register, add an implicit def of reg. + LastDef->addOperand(MachineOperand::CreateReg(Reg, + true/*IsDef*/, true/*IsImp*/)); // Remember this use. PhysRegUse[Reg] = MI; Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll?rev=88690&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-13-CoalescerCrash.ll Fri Nov 13 14:36:40 2009 @@ -0,0 +1,20 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s +; PR5410 + +%0 = type { float, float, float, float } +%pln = type { %vec, float } +%vec = type { [4 x float] } + +define arm_aapcs_vfpcc float @aaa(%vec* nocapture %ustart, %vec* nocapture %udir, %vec* nocapture %vstart, %vec* nocapture %vdir, %vec* %upoint, %vec* %vpoint) { +entry: + br i1 undef, label %bb81, label %bb48 + +bb48: ; preds = %entry + %0 = call arm_aapcs_vfpcc %0 @bbb(%pln* undef, %vec* %vstart, %vec* undef) nounwind ; <%0> [#uses=0] + ret float 0.000000e+00 + +bb81: ; preds = %entry + ret float 0.000000e+00 +} + +declare arm_aapcs_vfpcc %0 @bbb(%pln* nocapture, %vec* nocapture, %vec* nocapture) nounwind From criswell at cs.uiuc.edu Fri Nov 13 14:51:04 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 13 Nov 2009 14:51:04 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/links.html Message-ID: <200911132051.nADKp4s7001883@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: links.html updated: 1.2 -> 1.3 --- Log message: Added space to make the blue box big enough. --- Diffs of the changes: (+1 -0) links.html | 1 + 1 files changed, 1 insertion(+) Index: llvm-www/safecode/links.html diff -u llvm-www/safecode/links.html:1.2 llvm-www/safecode/links.html:1.3 --- llvm-www/safecode/links.html:1.2 Tue Nov 3 09:37:22 2009 +++ llvm-www/safecode/links.html Fri Nov 13 14:50:09 2009 @@ -62,6 +62,7 @@

      +


      From gohman at apple.com Fri Nov 13 15:02:15 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Nov 2009 21:02:15 -0000 Subject: [llvm-commits] [llvm] r88692 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/tail-opts.ll Message-ID: <200911132102.nADL2GpT020550@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 15:02:15 2009 New Revision: 88692 URL: http://llvm.org/viewvc/llvm-project?rev=88692&view=rev Log: When optimizing for size, don't tail-merge unless it's likely to be a code-size win, and not when it's only likely to be code-size neutral, such as when only a single instruction would be eliminated and a new branch would be required. This fixes rdar://7392894. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/test/CodeGen/X86/tail-opts.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=88692&r1=88691&r2=88692&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Fri Nov 13 15:02:15 2009 @@ -519,21 +519,24 @@ return true; // If both blocks have an unconditional branch temporarily stripped out, - // treat that as an additional common instruction. - if (MBB1 != PredBB && MBB2 != PredBB && + // count that as an additional common instruction for the following + // heuristics. + unsigned EffectiveTailLen = CommonTailLen; + if (SuccBB && MBB1 != PredBB && MBB2 != PredBB && !MBB1->back().getDesc().isBarrier() && !MBB2->back().getDesc().isBarrier()) - --minCommonTailLength; + ++EffectiveTailLen; // Check if the common tail is long enough to be worthwhile. - if (CommonTailLen >= minCommonTailLength) + if (EffectiveTailLen >= minCommonTailLength) return true; - // If we are optimizing for code size, 1 instruction in common is enough if - // we don't have to split a block. At worst we will be replacing a - // fallthrough into the common tail with a branch, which at worst breaks - // even with falling through into the duplicated common tail. - if (MF->getFunction()->hasFnAttr(Attribute::OptimizeForSize) && + // If we are optimizing for code size, 2 instructions in common is enough if + // we don't have to split a block. At worst we will be introducing 1 new + // branch instruction, which is likely to be smaller than the 2 + // instructions that would be deleted in the merge. + if (EffectiveTailLen >= 2 && + MF->getFunction()->hasFnAttr(Attribute::OptimizeForSize) && (I1 == MBB1->begin() || I2 == MBB2->begin())) return true; Modified: llvm/trunk/test/CodeGen/X86/tail-opts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-opts.ll?rev=88692&r1=88691&r2=88692&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tail-opts.ll (original) +++ llvm/trunk/test/CodeGen/X86/tail-opts.ll Fri Nov 13 15:02:15 2009 @@ -293,3 +293,116 @@ } declare void @func() + +; one - One instruction may be tail-duplicated even with optsize. + +; CHECK: one: +; CHECK: movl $0, XYZ(%rip) +; CHECK: movl $0, XYZ(%rip) + + at XYZ = external global i32 + +define void @one() nounwind optsize { +entry: + %0 = icmp eq i32 undef, 0 + br i1 %0, label %bbx, label %bby + +bby: + switch i32 undef, label %bb7 [ + i32 16, label %return + ] + +bb7: + volatile store i32 0, i32* @XYZ + unreachable + +bbx: + switch i32 undef, label %bb12 [ + i32 128, label %return + ] + +bb12: + volatile store i32 0, i32* @XYZ + unreachable + +return: + ret void +} + +; two - Same as one, but with two instructions in the common +; tail instead of one. This is too much to be merged, given +; the optsize attribute. + +; CHECK: two: +; CHECK-NOT: XYZ +; CHECK: movl $0, XYZ(%rip) +; CHECK: movl $1, XYZ(%rip) +; CHECK-NOT: XYZ +; CHECK: ret + +define void @two() nounwind optsize { +entry: + %0 = icmp eq i32 undef, 0 + br i1 %0, label %bbx, label %bby + +bby: + switch i32 undef, label %bb7 [ + i32 16, label %return + ] + +bb7: + volatile store i32 0, i32* @XYZ + volatile store i32 1, i32* @XYZ + unreachable + +bbx: + switch i32 undef, label %bb12 [ + i32 128, label %return + ] + +bb12: + volatile store i32 0, i32* @XYZ + volatile store i32 1, i32* @XYZ + unreachable + +return: + ret void +} + +; two_nosize - Same as two, but without the optsize attribute. +; Now two instructions are enough to be tail-duplicated. + +; CHECK: two_nosize: +; CHECK: movl $0, XYZ(%rip) +; CHECK: movl $1, XYZ(%rip) +; CHECK: movl $0, XYZ(%rip) +; CHECK: movl $1, XYZ(%rip) + +define void @two_nosize() nounwind { +entry: + %0 = icmp eq i32 undef, 0 + br i1 %0, label %bbx, label %bby + +bby: + switch i32 undef, label %bb7 [ + i32 16, label %return + ] + +bb7: + volatile store i32 0, i32* @XYZ + volatile store i32 1, i32* @XYZ + unreachable + +bbx: + switch i32 undef, label %bb12 [ + i32 128, label %return + ] + +bb12: + volatile store i32 0, i32* @XYZ + volatile store i32 1, i32* @XYZ + unreachable + +return: + ret void +} From criswell at uiuc.edu Fri Nov 13 15:11:38 2009 From: criswell at uiuc.edu (John Criswell) Date: Fri, 13 Nov 2009 21:11:38 -0000 Subject: [llvm-commits] [poolalloc] r88693 - /poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200911132111.nADLBd9P020958@zion.cs.uiuc.edu> Author: criswell Date: Fri Nov 13 15:11:38 2009 New Revision: 88693 URL: http://llvm.org/viewvc/llvm-project?rev=88693&view=rev Log: Changed the creation of a NULL pointer to use getNullValue() since pointers aren't aggregate types. Fix provided by Harmen van der Spek. Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=88693&r1=88692&r2=88693&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Fri Nov 13 15:11:38 2009 @@ -743,7 +743,7 @@ // pool descriptors to pass in... std::vector Args; for (unsigned i = 0, e = ArgNodes.size(); i != e; ++i) { - Value *ArgVal = ConstantAggregateZero::get(PoolAllocate::PoolDescPtrTy); + Value *ArgVal = Constant::getNullValue(PoolAllocate::PoolDescPtrTy); if (NodeMapping.count(ArgNodes[i])) if (DSNode *LocalNode = NodeMapping[ArgNodes[i]].getNode()) if (FI.PoolDescriptors.count(LocalNode)) From greened at obbligato.org Fri Nov 13 15:34:57 2009 From: greened at obbligato.org (David Greene) Date: Fri, 13 Nov 2009 21:34:57 -0000 Subject: [llvm-commits] [llvm] r88697 - in /llvm/trunk: lib/CodeGen/AsmPrinter/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/AsmPrinter/ lib/Target/Blackfin/AsmPrinter/ lib/Target/CellSPU/AsmPrinter/ lib/Target/MSP430/AsmPrinter/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/AsmPrinter/ lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/AsmPrinter/ lib/Target/SystemZ/AsmPrinter/ lib/Target/X86/AsmPrinter/ lib/Target/XCore/AsmPrinter/ test/FrontendC++/ Message-ID: <200911132134.nADLYwf2021852@zion.cs.uiuc.edu> Author: greened Date: Fri Nov 13 15:34:57 2009 New Revision: 88697 URL: http://llvm.org/viewvc/llvm-project?rev=88697&view=rev Log: Move DebugInfo checks into EmitComments and remove them from target-specific AsmPrinters. Not all comments need DebugInfo. Re-enable the line numbers comment test. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -18,6 +18,7 @@ #include "llvm/Module.h" #include "llvm/CodeGen/GCMetadataPrinter.h" #include "llvm/CodeGen/MachineConstantPool.h" +#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h" @@ -35,6 +36,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetOptions.h" @@ -1822,21 +1824,28 @@ /// EmitComments - Pretty-print comments for instructions void AsmPrinter::EmitComments(const MachineInstr &MI) const { - assert(VerboseAsm && !MI.getDebugLoc().isUnknown()); - - DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); + if (!VerboseAsm) + return; + + bool Newline = false; + + if (!MI.getDebugLoc().isUnknown()) { + DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); + + // Print source line info. + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << " SrcLine "; + if (DLT.Scope) { + DICompileUnit CU(DLT.Scope); + if (!CU.isNull()) + O << CU.getFilename() << " "; + } + O << DLT.Line; + if (DLT.Col != 0) + O << ":" << DLT.Col; + Newline = true; + } - // Print source line info. - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " SrcLine "; - if (DLT.Scope) { - DICompileUnit CU(DLT.Scope); - if (!CU.isNull()) - O << CU.getFilename() << " "; - } - O << DLT.Line; - if (DLT.Col != 0) - O << ":" << DLT.Col; } /// PrintChildLoopComment - Print comments about child loops within @@ -1867,8 +1876,7 @@ } /// EmitComments - Pretty-print comments for basic blocks -void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const -{ +void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const { if (VerboseAsm) { // Add loop depth information const MachineLoop *loop = LI->getLoopFor(&MBB); Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -1086,7 +1086,7 @@ printInstruction(MI); } - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; processDebugLoc(MI, false); Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -178,7 +178,7 @@ processDebugLoc(II, true); printInstruction(II); - if (VerboseAsm && !II->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*II); O << '\n'; processDebugLoc(II, false); Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -143,7 +143,7 @@ processDebugLoc(II, true); printInstruction(II); - if (VerboseAsm && !II->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*II); O << '\n'; Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -406,7 +406,7 @@ ++EmittedInsts; processDebugLoc(MI, true); printInstruction(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); processDebugLoc(MI, false); O << '\n'; Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -239,7 +239,7 @@ printInstructionThroughMCStreamer(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -282,7 +282,7 @@ // Print the assembly for the instruction. printInstruction(II); - if (VerboseAsm && !II->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*II); O << '\n'; Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -46,7 +46,7 @@ bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { processDebugLoc(MI, true); printInstruction(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; processDebugLoc(MI, false); Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -594,7 +594,7 @@ printInstruction(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -126,7 +126,7 @@ processDebugLoc(II, true); printInstruction(II); - if (VerboseAsm && !II->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*II); O << '\n'; processDebugLoc(II, false); Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -155,7 +155,7 @@ // Call the autogenerated instruction printer routines. printInstruction(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -651,7 +651,7 @@ printInstructionThroughMCStreamer(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Fri Nov 13 15:34:57 2009 @@ -361,7 +361,7 @@ return; } printInstruction(MI); - if (VerboseAsm && !MI->getDebugLoc().isUnknown()) + if (VerboseAsm) EmitComments(*MI); O << '\n'; Modified: llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-07-15-LineNumbers.cpp?rev=88697&r1=88696&r2=88697&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp (original) +++ llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp Fri Nov 13 15:34:57 2009 @@ -2,7 +2,6 @@ // print line numbers in asm. // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ // RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep {# SrcLine 25} -// XFAIL: * #include From dpatel at apple.com Fri Nov 13 15:45:04 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 13 Nov 2009 21:45:04 -0000 Subject: [llvm-commits] [llvm] r88700 - /llvm/trunk/include/llvm/Analysis/DebugInfo.h Message-ID: <200911132145.nADLj4mj022306@zion.cs.uiuc.edu> Author: dpatel Date: Fri Nov 13 15:45:04 2009 New Revision: 88700 URL: http://llvm.org/viewvc/llvm-project?rev=88700&view=rev Log: Do not use value handle to wrap MDNode in DIDescriptor. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=88700&r1=88699&r2=88700&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Fri Nov 13 15:45:04 2009 @@ -44,9 +44,11 @@ class Instruction; class LLVMContext; + /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. This should not + /// be stored in a container, because underly MDNode may change in certain situations. class DIDescriptor { protected: - TrackingVH DbgNode; + MDNode *DbgNode; /// DIDescriptor constructor. If the specified node is non-null, check /// to make sure that the tag in the descriptor matches 'RequiredTag'. If From dpatel at apple.com Fri Nov 13 15:52:11 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 13 Nov 2009 21:52:11 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r88701 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200911132152.nADLqBgt022568@zion.cs.uiuc.edu> Author: dpatel Date: Fri Nov 13 15:52:10 2009 New Revision: 88701 URL: http://llvm.org/viewvc/llvm-project?rev=88701&view=rev Log: Avoid using c_str() on temp. string. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=88701&r1=88700&r2=88701&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Fri Nov 13 15:52:10 2009 @@ -398,7 +398,8 @@ // Gather location information. expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl)); DIType TyD = getOrCreateType(TREE_TYPE(decl)); - const char *DispName = GV->getNameStr().c_str(); + std::string DispNameStr = GV->getNameStr(); + const char *DispName = DispNameStr.c_str(); if (DECL_NAME(decl)) { if (IDENTIFIER_POINTER(DECL_NAME(decl))) DispName = IDENTIFIER_POINTER(DECL_NAME(decl)); From gohman at apple.com Fri Nov 13 15:55:31 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Nov 2009 21:55:31 -0000 Subject: [llvm-commits] [llvm] r88703 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200911132155.nADLtVWF022702@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 15:55:31 2009 New Revision: 88703 URL: http://llvm.org/viewvc/llvm-project?rev=88703&view=rev Log: Use .data() instead of .c_str() when nul-termination is not needed. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=88703&r1=88702&r2=88703&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Fri Nov 13 15:55:31 2009 @@ -56,7 +56,7 @@ /// Construct a string ref from an std::string. /*implicit*/ StringRef(const std::string &Str) - : Data(Str.c_str()), Length(Str.length()) {} + : Data(Str.data()), Length(Str.length()) {} /// @} /// @name Iterators Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=88703&r1=88702&r2=88703&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Nov 13 15:55:31 2009 @@ -729,7 +729,7 @@ /// Special characters are emitted properly. /// \literal (Eg. '\t') \endliteral void AsmPrinter::EmitString(const std::string &String) const { - EmitString(String.c_str(), String.size()); + EmitString(String.data(), String.size()); } void AsmPrinter::EmitString(const char *String, unsigned Size) const { From stoklund at 2pi.dk Fri Nov 13 15:55:54 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Nov 2009 21:55:54 -0000 Subject: [llvm-commits] [llvm] r88704 - /llvm/trunk/lib/CodeGen/MachineVerifier.cpp Message-ID: <200911132155.nADLtsDd022726@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 15:55:54 2009 New Revision: 88704 URL: http://llvm.org/viewvc/llvm-project?rev=88704&view=rev Log: Fix polarity of a CFG check in machine verifier. Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=88704&r1=88703&r2=88704&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Fri Nov 13 15:55:54 2009 @@ -287,7 +287,18 @@ markReachable(&MF->front()); } -void MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) { +// Does iterator point to a and b as the first two elements? +bool matchPair(MachineBasicBlock::const_succ_iterator i, + const MachineBasicBlock *a, const MachineBasicBlock *b) { + if (*i == a) + return *++i == b; + if (*i == b) + return *++i == a; + return false; +} + +void +MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) { const TargetInstrInfo *TII = MF->getTarget().getInstrInfo(); // Start with minimal CFG sanity checks. @@ -379,8 +390,7 @@ } if (MBB->succ_size() != 2) { report("MBB exits via conditional branch/fall-through but doesn't have " "exactly two CFG successors!", MBB); - } else if ((MBB->succ_begin()[0] == TBB && MBB->succ_end()[1] == MBBI) || - (MBB->succ_begin()[1] == TBB && MBB->succ_end()[0] == MBBI)) { + } else if (!matchPair(MBB->succ_begin(), TBB, MBBI)) { report("MBB exits via conditional branch/fall-through but the CFG " "successors don't match the actual successors!", MBB); } @@ -400,8 +410,7 @@ if (MBB->succ_size() != 2) { report("MBB exits via conditional branch/branch but doesn't have " "exactly two CFG successors!", MBB); - } else if ((MBB->succ_begin()[0] == TBB && MBB->succ_end()[1] == FBB) || - (MBB->succ_begin()[1] == TBB && MBB->succ_end()[0] == FBB)) { + } else if (!matchPair(MBB->succ_begin(), TBB, FBB)) { report("MBB exits via conditional branch/branch but the CFG " "successors don't match the actual successors!", MBB); } From stoklund at 2pi.dk Fri Nov 13 15:56:01 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Nov 2009 21:56:01 -0000 Subject: [llvm-commits] [llvm] r88705 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200911132156.nADLu2ga022740@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 15:56:01 2009 New Revision: 88705 URL: http://llvm.org/viewvc/llvm-project?rev=88705&view=rev Log: The instruction pointer %RIP is a reserved register on x86_64. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=88705&r1=88704&r2=88705&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Fri Nov 13 15:56:01 2009 @@ -392,6 +392,11 @@ Reserved.set(X86::SP); Reserved.set(X86::SPL); + // Set the instruction pointer register and its aliases as reserved. + Reserved.set(X86::RIP); + Reserved.set(X86::EIP); + Reserved.set(X86::IP); + // Set the frame-pointer register and its aliases as reserved if needed. if (hasFP(MF)) { Reserved.set(X86::RBP); From stoklund at 2pi.dk Fri Nov 13 15:56:09 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Nov 2009 21:56:09 -0000 Subject: [llvm-commits] [llvm] r88706 - in /llvm/trunk: include/llvm/CodeGen/MachineFunction.h lib/CodeGen/MachineVerifier.cpp Message-ID: <200911132156.nADLu9xx022760@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 15:56:09 2009 New Revision: 88706 URL: http://llvm.org/viewvc/llvm-project?rev=88706&view=rev Log: Add MachineFunction::verify() to call the machine code verifier directly. Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/lib/CodeGen/MachineVerifier.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=88706&r1=88705&r2=88706&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Fri Nov 13 15:56:09 2009 @@ -232,6 +232,10 @@ /// void dump() const; + /// verify - Run the current MachineFunction through the machine code + /// verifier, useful for debugger use. + void verify() const; + // Provide accessors for the MachineBasicBlock list... typedef BasicBlockListType::iterator iterator; typedef BasicBlockListType::const_iterator const_iterator; Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=88706&r1=88705&r2=88706&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Fri Nov 13 15:56:09 2009 @@ -175,6 +175,10 @@ return new MachineVerifier(allowPhysDoubleDefs); } +void MachineFunction::verify() const { + MachineVerifier().runOnMachineFunction(const_cast(*this)); +} + bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) { raw_ostream *OutFile = 0; if (OutFileName) { From stoklund at 2pi.dk Fri Nov 13 15:56:15 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Nov 2009 21:56:15 -0000 Subject: [llvm-commits] [llvm] r88707 - in /llvm/trunk/lib/CodeGen: PHIElimination.cpp PHIElimination.h Message-ID: <200911132156.nADLuFU7022775@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 15:56:15 2009 New Revision: 88707 URL: http://llvm.org/viewvc/llvm-project?rev=88707&view=rev Log: Fix PHIElimination optimization that uses MBB->getBasicBlock. The BasicBlock associated with a MachineBasicBlock does not necessarily correspond to the code in the MBB. Don't insert a new IR BasicBlock when splitting critical edges. We are not supposed to modify the IR during codegen, and we should be able to do just fine with a NULL BB. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=88707&r1=88706&r2=88707&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri Nov 13 15:56:15 2009 @@ -15,8 +15,6 @@ #define DEBUG_TYPE "phielim" #include "PHIElimination.h" -#include "llvm/BasicBlock.h" -#include "llvm/Instructions.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -126,26 +124,28 @@ return true; } -// FindCopyInsertPoint - Find a safe place in MBB to insert a copy from SrcReg. -// This needs to be after any def or uses of SrcReg, but before any subsequent -// point where control flow might jump out of the basic block. +// FindCopyInsertPoint - Find a safe place in MBB to insert a copy from SrcReg +// when following the CFG edge to SuccMBB. This needs to be after any def of +// SrcReg, but before any subsequent point where control flow might jump out of +// the basic block. MachineBasicBlock::iterator llvm::PHIElimination::FindCopyInsertPoint(MachineBasicBlock &MBB, + MachineBasicBlock &SuccMBB, unsigned SrcReg) { // Handle the trivial case trivially. if (MBB.empty()) return MBB.begin(); - // If this basic block does not contain an invoke, then control flow always - // reaches the end of it, so place the copy there. The logic below works in - // this case too, but is more expensive. - if (!isa(MBB.getBasicBlock()->getTerminator())) + // Usually, we just want to insert the copy before the first terminator + // instruction. However, for the edge going to a landing pad, we must insert + // the copy before the call/invoke instruction. + if (!SuccMBB.isLandingPad()) return MBB.getFirstTerminator(); - // Discover any definition/uses in this basic block. + // Discover any definitions in this basic block. SmallPtrSet DefUsesInMBB; - for (MachineRegisterInfo::reg_iterator RI = MRI->reg_begin(SrcReg), - RE = MRI->reg_end(); RI != RE; ++RI) { + for (MachineRegisterInfo::def_iterator RI = MRI->def_begin(SrcReg), + RE = MRI->def_end(); RI != RE; ++RI) { MachineInstr *DefUseMI = &*RI; if (DefUseMI->getParent() == &MBB) DefUsesInMBB.insert(DefUseMI); @@ -153,14 +153,14 @@ MachineBasicBlock::iterator InsertPoint; if (DefUsesInMBB.empty()) { - // No def/uses. Insert the copy at the start of the basic block. + // No defs. Insert the copy at the start of the basic block. InsertPoint = MBB.begin(); } else if (DefUsesInMBB.size() == 1) { - // Insert the copy immediately after the definition/use. + // Insert the copy immediately after the def. InsertPoint = *DefUsesInMBB.begin(); ++InsertPoint; } else { - // Insert the copy immediately after the last definition/use. + // Insert the copy immediately after the last def. InsertPoint = MBB.end(); while (!DefUsesInMBB.count(&*--InsertPoint)) {} ++InsertPoint; @@ -272,7 +272,8 @@ // Find a safe location to insert the copy, this may be the first terminator // in the block (or end()). - MachineBasicBlock::iterator InsertPos = FindCopyInsertPoint(opBlock, SrcReg); + MachineBasicBlock::iterator InsertPos = + FindCopyInsertPoint(opBlock, MBB, SrcReg); // Insert the copy. TII->copyRegToReg(opBlock, InsertPos, IncomingReg, SrcReg, RC, RC); @@ -427,21 +428,8 @@ assert(A && B && "Missing MBB end point"); ++NumSplits; - BasicBlock *ABB = const_cast(A->getBasicBlock()); - BasicBlock *BBB = const_cast(B->getBasicBlock()); - assert(ABB && BBB && "End points must have a basic block"); - BasicBlock *BB = BasicBlock::Create(BBB->getContext(), - ABB->getName() + "." + BBB->getName() + - "_phi_edge"); - Function *F = ABB->getParent(); - F->getBasicBlockList().insert(F->end(), BB); - - BranchInst::Create(BBB, BB); - // We could do more here to produce correct IR, compare - // llvm::SplitCriticalEdge - MachineFunction *MF = A->getParent(); - MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(BB); + MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(); MF->push_back(NMBB); DEBUG(errs() << "PHIElimination splitting critical edge:" " BB#" << A->getNumber() Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=88707&r1=88706&r2=88707&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Fri Nov 13 15:56:15 2009 @@ -110,11 +110,12 @@ MachineBasicBlock *SplitCriticalEdge(MachineBasicBlock *A, MachineBasicBlock *B); - // FindCopyInsertPoint - Find a safe place in MBB to insert a copy from - // SrcReg. This needs to be after any def or uses of SrcReg, but before - // any subsequent point where control flow might jump out of the basic - // block. + /// FindCopyInsertPoint - Find a safe place in MBB to insert a copy from + /// SrcReg when following the CFG edge to SuccMBB. This needs to be after + /// any def of SrcReg, but before any subsequent point where control flow + /// might jump out of the basic block. MachineBasicBlock::iterator FindCopyInsertPoint(MachineBasicBlock &MBB, + MachineBasicBlock &SuccMBB, unsigned SrcReg); // SkipPHIsAndLabels - Copies need to be inserted after phi nodes and From isanbard at gmail.com Fri Nov 13 15:58:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 13 Nov 2009 21:58:54 -0000 Subject: [llvm-commits] [llvm] r88708 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200911132158.nADLwsB4022896@zion.cs.uiuc.edu> Author: void Date: Fri Nov 13 15:58:54 2009 New Revision: 88708 URL: http://llvm.org/viewvc/llvm-project?rev=88708&view=rev Log: Disable the JITTest.NoStubs test for Darwin PPC. It apparently doesn't implement emitFunctionStubAtAddr. Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=88708&r1=88707&r2=88708&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Fri Nov 13 15:58:54 2009 @@ -458,6 +458,9 @@ NumTablesDeallocated); } +#if !defined(__APPLE__) || \ + !(defined(__POWERPC__) || defined (__ppc__) || \ + defined(_POWER) || defined(_ARCH_PPC)) typedef int (*FooPtr) (); TEST_F(JITTest, NoStubs) { @@ -495,6 +498,7 @@ ASSERT_EQ(stubsBefore, RJMM->stubsAllocated); } +#endif // This code is copied from JITEventListenerTest, but it only runs once for all // the tests in this directory. Everything seems fine, but that's strange From echristo at apple.com Fri Nov 13 16:00:14 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 13 Nov 2009 14:00:14 -0800 Subject: [llvm-commits] [llvm] r88708 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp In-Reply-To: <200911132158.nADLwsB4022896@zion.cs.uiuc.edu> References: <200911132158.nADLwsB4022896@zion.cs.uiuc.edu> Message-ID: <269ADFA7-6383-4A3C-9B91-7D4FAF05724E@apple.com> On Nov 13, 2009, at 1:58 PM, Bill Wendling wrote: > Author: void > Date: Fri Nov 13 15:58:54 2009 > New Revision: 88708 > > URL: http://llvm.org/viewvc/llvm-project?rev=88708&view=rev > Log: > Disable the JITTest.NoStubs test for Darwin PPC. It apparently doesn't implement > emitFunctionStubAtAddr. > Ugh. Lovely, thanks. -eric From gohman at apple.com Fri Nov 13 16:24:13 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Nov 2009 22:24:13 -0000 Subject: [llvm-commits] [llvm] r88711 - /llvm/trunk/include/llvm/Value.h Message-ID: <200911132224.nADMODnx023994@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 16:24:13 2009 New Revision: 88711 URL: http://llvm.org/viewvc/llvm-project?rev=88711&view=rev Log: Move the FixedStackPseudoSourceValueVal enum value before InstructionVal so that isa doesn't return true for FixedStackPseudoSourceValue values. This fixes a variety of problems, including crashes with -debug and -print-machineinstrs. Also, add a comment to warn about this. Modified: llvm/trunk/include/llvm/Value.h Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=88711&r1=88710&r2=88711&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Fri Nov 13 16:24:13 2009 @@ -224,9 +224,11 @@ NamedMDNodeVal, // This is an instance of NamedMDNode InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue - InstructionVal, // This is an instance of Instruction FixedStackPseudoSourceValueVal, // This is an instance of // FixedStackPseudoSourceValue + InstructionVal, // This is an instance of Instruction + // Enum values starting at InstructionVal are used for Instructions; + // don't add new values here! // Markers: ConstantFirstVal = FunctionVal, From grosbach at apple.com Fri Nov 13 16:35:57 2009 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Nov 2009 22:35:57 -0000 Subject: [llvm-commits] [test-suite] r88713 - /test-suite/trunk/Makefile.programs Message-ID: <200911132235.nADMZwm9024458@zion.cs.uiuc.edu> Author: grosbach Date: Fri Nov 13 16:35:57 2009 New Revision: 88713 URL: http://llvm.org/viewvc/llvm-project?rev=88713&view=rev Log: adjust jump tables as llcbeta for arm Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=88713&r1=88712&r2=88713&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Fri Nov 13 16:35:57 2009 @@ -244,11 +244,12 @@ LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -combiner-alias-analysis +LLCBETAOPTION := -arm-adjust-jump-tables #-schedule-livein-copies endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -combiner-alias-analysis +LLCBETAOPTION := -arm-adjust-jump-tables +#-combiner-alias-analysis #-enable-thumb-reg-scavenging endif From echristo at apple.com Fri Nov 13 17:00:14 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 13 Nov 2009 23:00:14 -0000 Subject: [llvm-commits] [llvm] r88715 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200911132300.nADN0Ei2025394@zion.cs.uiuc.edu> Author: echristo Date: Fri Nov 13 17:00:14 2009 New Revision: 88715 URL: http://llvm.org/viewvc/llvm-project?rev=88715&view=rev Log: Print out something, even if it's non-parseable later when we've got ghost linkage. It's better than aborting. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=88715&r1=88714&r2=88715&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Fri Nov 13 17:00:14 2009 @@ -1497,8 +1497,8 @@ case GlobalValue::AvailableExternallyLinkage: Out << "available_externally "; break; - case GlobalValue::GhostLinkage: - llvm_unreachable("GhostLinkage not allowed in AsmWriter!"); + // This is invalid syntax and just a debugging aid. + case GlobalValue::GhostLinkage: Out << "ghost "; break; } } @@ -1514,6 +1514,11 @@ } void AssemblyWriter::printGlobal(const GlobalVariable *GV) { + // If we're going to print a global that has GhostLinkage + // materialize it now. + if (GV->getLinkage() == GlobalValue::GhostLinkage) { + } + WriteAsOperandInternal(Out, GV, &TypePrinter, &Machine); Out << " = "; From echristo at apple.com Fri Nov 13 17:08:48 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 13 Nov 2009 23:08:48 -0000 Subject: [llvm-commits] [llvm] r88716 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200911132308.nADN8m93025663@zion.cs.uiuc.edu> Author: echristo Date: Fri Nov 13 17:08:47 2009 New Revision: 88716 URL: http://llvm.org/viewvc/llvm-project?rev=88716&view=rev Log: Remove extraneous commit. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=88716&r1=88715&r2=88716&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Fri Nov 13 17:08:47 2009 @@ -1514,11 +1514,6 @@ } void AssemblyWriter::printGlobal(const GlobalVariable *GV) { - // If we're going to print a global that has GhostLinkage - // materialize it now. - if (GV->getLinkage() == GlobalValue::GhostLinkage) { - } - WriteAsOperandInternal(Out, GV, &TypePrinter, &Machine); Out << " = "; From evan.cheng at apple.com Fri Nov 13 17:16:41 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 13 Nov 2009 23:16:41 -0000 Subject: [llvm-commits] [llvm] r88719 - in /llvm/trunk: lib/CodeGen/VirtRegRewriter.cpp test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll Message-ID: <200911132316.nADNGgiS025939@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 17:16:41 2009 New Revision: 88719 URL: http://llvm.org/viewvc/llvm-project?rev=88719&view=rev Log: Fix PR5411. Bug in UpdateKills. A reg def partially define its super-registers. Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=88719&r1=88718&r2=88719&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Fri Nov 13 17:16:41 2009 @@ -583,6 +583,10 @@ RegKills.reset(*SR); KillOps[*SR] = NULL; } + for (const unsigned *SR = TRI->getSuperRegisters(Reg); *SR; ++SR) { + RegKills.reset(*SR); + KillOps[*SR] = NULL; + } } } Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll?rev=88719&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert.ll Fri Nov 13 17:16:41 2009 @@ -0,0 +1,42 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s +; PR5411 + +%bar = type { %quad, float, float, [3 x %quux*], [3 x %bar*], [2 x %bar*], [3 x i8], i8 } +%baz = type { %bar*, i32 } +%foo = type { i8, %quuz, %quad, float, [64 x %quux], [128 x %bar], i32, %baz, %baz } +%quad = type { [4 x float] } +%quux = type { %quad, %quad } +%quuz = type { [4 x %quux*], [4 x float], i32 } + +define arm_aapcs_vfpcc %bar* @aaa(%foo* nocapture %this, %quux* %a, %quux* %b, %quux* %c, i8 zeroext %forced) { +entry: + br i1 undef, label %bb85, label %bb + +bb: ; preds = %entry + %0 = getelementptr inbounds %bar* null, i32 0, i32 0, i32 0, i32 2 ; [#uses=2] + %1 = load float* undef, align 4 ; [#uses=1] + %2 = fsub float 0.000000e+00, undef ; [#uses=2] + %3 = fmul float 0.000000e+00, undef ; [#uses=1] + %4 = load float* %0, align 4 ; [#uses=3] + %5 = fmul float %4, %2 ; [#uses=1] + %6 = fsub float %3, %5 ; [#uses=1] + %7 = fmul float %4, undef ; [#uses=1] + %8 = fsub float %7, undef ; [#uses=1] + %9 = fmul float undef, %2 ; [#uses=1] + %10 = fmul float 0.000000e+00, undef ; [#uses=1] + %11 = fsub float %9, %10 ; [#uses=1] + %12 = fmul float undef, %6 ; [#uses=1] + %13 = fmul float 0.000000e+00, %8 ; [#uses=1] + %14 = fadd float %12, %13 ; [#uses=1] + %15 = fmul float %1, %11 ; [#uses=1] + %16 = fadd float %14, %15 ; [#uses=1] + %17 = select i1 undef, float undef, float %16 ; [#uses=1] + %18 = fdiv float %17, 0.000000e+00 ; [#uses=1] + store float %18, float* undef, align 4 + %19 = fmul float %4, undef ; [#uses=1] + store float %19, float* %0, align 4 + ret %bar* null + +bb85: ; preds = %entry + ret %bar* null +} From lhames at gmail.com Fri Nov 13 18:02:52 2009 From: lhames at gmail.com (Lang Hames) Date: Sat, 14 Nov 2009 00:02:52 -0000 Subject: [llvm-commits] [llvm] r88725 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/SlotIndexes.cpp lib/CodeGen/Spiller.cpp Message-ID: <200911140002.nAE02q3F027475@zion.cs.uiuc.edu> Author: lhames Date: Fri Nov 13 18:02:51 2009 New Revision: 88725 URL: http://llvm.org/viewvc/llvm-project?rev=88725&view=rev Log: Added an API to the SlotIndexes pass to allow new instructions to be inserted into the numbering. PreAllocSplitting is now using this API to insert code. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/SlotIndexes.cpp llvm/trunk/lib/CodeGen/Spiller.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=88725&r1=88724&r2=88725&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Fri Nov 13 18:02:51 2009 @@ -189,20 +189,8 @@ return indexes_->getMBBFromIndex(index); } - bool hasGapBeforeInstr(SlotIndex index) { - return indexes_->hasGapBeforeInstr(index); - } - - bool hasGapAfterInstr(SlotIndex index) { - return indexes_->hasGapAfterInstr(index); - } - - SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) { - return indexes_->findGapBeforeInstr(index, furthest); - } - - void InsertMachineInstrInMaps(MachineInstr *MI, SlotIndex Index) { - indexes_->insertMachineInstrInMaps(MI, Index); + SlotIndex InsertMachineInstrInMaps(MachineInstr *MI) { + return indexes_->insertMachineInstrInMaps(MI); } void RemoveMachineInstrFromMaps(MachineInstr *MI) { @@ -219,7 +207,7 @@ } void renumber() { - indexes_->renumber(); + indexes_->renumberIndexes(); } BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; } Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=88725&r1=88724&r2=88725&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Fri Nov 13 18:02:51 2009 @@ -487,7 +487,7 @@ void dump() const; /// Renumber the index list, providing space for new instructions. - void renumber(); + void renumberIndexes(); /// Returns the zero index for this analysis. SlotIndex getZeroIndex() { @@ -647,99 +647,89 @@ return 0; } - /// Returns true if there is a gap in the numbering before the given index. - bool hasGapBeforeInstr(SlotIndex index) { - index = index.getBaseIndex(); - SlotIndex prevIndex = index.getPrevIndex(); - - if (prevIndex == getZeroIndex()) - return false; - - if (getInstructionFromIndex(prevIndex) == 0) - return true; - - if (prevIndex.distance(index) >= 2 * SlotIndex::NUM) - return true; - - return false; - } - - /// Returns true if there is a gap in the numbering after the given index. - bool hasGapAfterInstr(SlotIndex index) const { - // Not implemented yet. - assert(false && - "SlotIndexes::hasGapAfterInstr(SlotIndex) not implemented yet."); - return false; - } - - /// findGapBeforeInstr - Find an empty instruction slot before the - /// specified index. If "Furthest" is true, find one that's furthest - /// away from the index (but before any index that's occupied). - // FIXME: This whole method should go away in future. It should - // always be possible to insert code between existing indices. - SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) { - if (index == getZeroIndex()) - return getInvalidIndex(); - - index = index.getBaseIndex(); - SlotIndex prevIndex = index.getPrevIndex(); - - if (prevIndex == getZeroIndex()) - return getInvalidIndex(); - - // Try to reuse existing index objects with null-instrs. - if (getInstructionFromIndex(prevIndex) == 0) { - if (furthest) { - while (getInstructionFromIndex(prevIndex) == 0 && - prevIndex != getZeroIndex()) { - prevIndex = prevIndex.getPrevIndex(); - } - - prevIndex = prevIndex.getNextIndex(); - } - - assert(getInstructionFromIndex(prevIndex) == 0 && "Index list is broken."); - - return prevIndex; + /// Insert the given machine instruction into the mapping. Returns the + /// assigned index. + SlotIndex insertMachineInstrInMaps(MachineInstr *mi, + bool *deferredRenumber = 0) { + assert(mi2iMap.find(mi) == mi2iMap.end() && "Instr already indexed."); + + MachineBasicBlock *mbb = mi->getParent(); + + assert(mbb != 0 && "Instr must be added to function."); + + MBB2IdxMap::iterator mbbRangeItr = mbb2IdxMap.find(mbb); + + assert(mbbRangeItr != mbb2IdxMap.end() && + "Instruction's parent MBB has not been added to SlotIndexes."); + + MachineBasicBlock::iterator miItr(mi); + bool needRenumber = false; + IndexListEntry *newEntry; + + IndexListEntry *prevEntry; + if (miItr == mbb->begin()) { + // If mi is at the mbb beginning, get the prev index from the mbb. + prevEntry = &mbbRangeItr->second.first.entry(); + } else { + // Otherwise get it from the previous instr. + MachineBasicBlock::iterator pItr(prior(miItr)); + prevEntry = &getInstructionIndex(pItr).entry(); } - int dist = prevIndex.distance(index); + // Get next entry from previous entry. + IndexListEntry *nextEntry = prevEntry->getNext(); + + // Get a number for the new instr, or 0 if there's no room currently. + // In the latter case we'll force a renumber later. + unsigned dist = nextEntry->getIndex() - prevEntry->getIndex(); + unsigned newNumber = dist > SlotIndex::NUM ? + prevEntry->getIndex() + ((dist >> 1) & ~3U) : 0; - // Double check that the spacing between this instruction and - // the last is sane. - assert(dist >= SlotIndex::NUM && - "Distance between indexes too small."); - - // If there's no gap return an invalid index. - if (dist < 2*SlotIndex::NUM) { - return getInvalidIndex(); + if (newNumber == 0) { + needRenumber = true; } - // Otherwise insert new index entries into the list using the - // gap in the numbering. - IndexListEntry *newEntry = - createEntry(0, prevIndex.entry().getIndex() + SlotIndex::NUM); + // Insert a new list entry for mi. + newEntry = createEntry(mi, newNumber); + insert(nextEntry, newEntry); + + SlotIndex newIndex(newEntry, SlotIndex::LOAD); + mi2iMap.insert(std::make_pair(mi, newIndex)); + + if (miItr == mbb->end()) { + // If this is the last instr in the MBB then we need to fix up the bb + // range: + mbbRangeItr->second.second = SlotIndex(newIndex, SlotIndex::STORE); + } - insert(&index.entry(), newEntry); + // Renumber if we need to. + if (needRenumber) { + if (deferredRenumber == 0) + renumberIndexes(); + else + *deferredRenumber = true; + } - // And return a pointer to the entry at the start of the gap. - return index.getPrevIndex(); + return newIndex; } - /// Insert the given machine instruction into the mapping at the given - /// index. - void insertMachineInstrInMaps(MachineInstr *mi, SlotIndex index) { - index = index.getBaseIndex(); - IndexListEntry *miEntry = &index.entry(); - assert(miEntry->getInstr() == 0 && "Index already in use."); - miEntry->setInstr(mi); - - assert(mi2iMap.find(mi) == mi2iMap.end() && - "MachineInstr already has an index."); + /// Add all instructions in the vector to the index list. This method will + /// defer renumbering until all instrs have been added, and should be + /// preferred when adding multiple instrs. + void insertMachineInstrsInMaps(SmallVectorImpl &mis) { + bool renumber = false; + + for (SmallVectorImpl::iterator + miItr = mis.begin(), miEnd = mis.end(); + miItr != miEnd; ++miItr) { + insertMachineInstrInMaps(*miItr, &renumber); + } - mi2iMap.insert(std::make_pair(mi, index)); + if (renumber) + renumberIndexes(); } + /// Remove the given machine instruction from the mapping. void removeMachineInstrFromMaps(MachineInstr *mi) { // remove index -> MachineInstr and Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=88725&r1=88724&r2=88725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Fri Nov 13 18:02:51 2009 @@ -133,17 +133,14 @@ private: - MachineBasicBlock::iterator - findNextEmptySlot(MachineBasicBlock*, MachineInstr*, - SlotIndex&); MachineBasicBlock::iterator findSpillPoint(MachineBasicBlock*, MachineInstr*, MachineInstr*, - SmallPtrSet&, SlotIndex&); + SmallPtrSet&); MachineBasicBlock::iterator findRestorePoint(MachineBasicBlock*, MachineInstr*, SlotIndex, - SmallPtrSet&, SlotIndex&); + SmallPtrSet&); int CreateSpillStackSlot(unsigned, const TargetRegisterClass *); @@ -163,7 +160,6 @@ bool Rematerialize(unsigned vreg, VNInfo* ValNo, MachineInstr* DefMI, MachineBasicBlock::iterator RestorePt, - SlotIndex RestoreIdx, SmallPtrSet& RefsInMBB); MachineInstr* FoldSpill(unsigned vreg, const TargetRegisterClass* RC, MachineInstr* DefMI, @@ -210,24 +206,6 @@ const PassInfo *const llvm::PreAllocSplittingID = &X; - -/// findNextEmptySlot - Find a gap after the given machine instruction in the -/// instruction index map. If there isn't one, return end(). -MachineBasicBlock::iterator -PreAllocSplitting::findNextEmptySlot(MachineBasicBlock *MBB, MachineInstr *MI, - SlotIndex &SpotIndex) { - MachineBasicBlock::iterator MII = MI; - if (++MII != MBB->end()) { - SlotIndex Index = - LIs->findGapBeforeInstr(LIs->getInstructionIndex(MII)); - if (Index != SlotIndex()) { - SpotIndex = Index; - return MII; - } - } - return MBB->end(); -} - /// findSpillPoint - Find a gap as far away from the given MI that's suitable /// for spilling the current live interval. The index must be before any /// defs and uses of the live interval register in the mbb. Return begin() if @@ -235,8 +213,7 @@ MachineBasicBlock::iterator PreAllocSplitting::findSpillPoint(MachineBasicBlock *MBB, MachineInstr *MI, MachineInstr *DefMI, - SmallPtrSet &RefsInMBB, - SlotIndex &SpillIndex) { + SmallPtrSet &RefsInMBB) { MachineBasicBlock::iterator Pt = MBB->begin(); MachineBasicBlock::iterator MII = MI; @@ -249,8 +226,6 @@ if (MII == EndPt || RefsInMBB.count(MII)) return Pt; while (MII != EndPt && !RefsInMBB.count(MII)) { - SlotIndex Index = LIs->getInstructionIndex(MII); - // We can't insert the spill between the barrier (a call), and its // corresponding call frame setup. if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode()) { @@ -261,9 +236,8 @@ } } continue; - } else if (LIs->hasGapBeforeInstr(Index)) { + } else { Pt = MII; - SpillIndex = LIs->findGapBeforeInstr(Index, true); } if (RefsInMBB.count(MII)) @@ -283,8 +257,7 @@ MachineBasicBlock::iterator PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI, SlotIndex LastIdx, - SmallPtrSet &RefsInMBB, - SlotIndex &RestoreIndex) { + SmallPtrSet &RefsInMBB) { // FIXME: Allow spill to be inserted to the beginning of the mbb. Update mbb // begin index accordingly. MachineBasicBlock::iterator Pt = MBB->end(); @@ -308,7 +281,6 @@ SlotIndex Index = LIs->getInstructionIndex(MII); if (Index > LastIdx) break; - SlotIndex Gap = LIs->findGapBeforeInstr(Index); // We can't insert a restore between the barrier (a call) and its // corresponding call frame teardown. @@ -317,9 +289,8 @@ if (MII == EndPt || RefsInMBB.count(MII)) return Pt; ++MII; } while (MII->getOpcode() != TRI->getCallFrameDestroyOpcode()); - } else if (Gap != SlotIndex()) { + } else { Pt = MII; - RestoreIndex = Gap; } if (RefsInMBB.count(MII)) @@ -742,7 +713,7 @@ DefIdx = DefIdx.getDefIndex(); assert(DI->getOpcode() != TargetInstrInfo::PHI && - "Following NewVN isPHIDef flag incorrect. Fix me!"); + "PHI instr in code during pre-alloc splitting."); VNInfo* NewVN = LI->getNextValue(DefIdx, 0, true, Alloc); // If the def is a move, set the copy field. @@ -898,25 +869,22 @@ bool PreAllocSplitting::Rematerialize(unsigned VReg, VNInfo* ValNo, MachineInstr* DefMI, MachineBasicBlock::iterator RestorePt, - SlotIndex RestoreIdx, SmallPtrSet& RefsInMBB) { MachineBasicBlock& MBB = *RestorePt->getParent(); MachineBasicBlock::iterator KillPt = BarrierMBB->end(); - SlotIndex KillIdx; if (!ValNo->isDefAccurate() || DefMI->getParent() == BarrierMBB) - KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB, KillIdx); + KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB); else - KillPt = findNextEmptySlot(DefMI->getParent(), DefMI, KillIdx); + KillPt = next(MachineBasicBlock::iterator(DefMI)); if (KillPt == DefMI->getParent()->end()) return false; TII->reMaterialize(MBB, RestorePt, VReg, 0, DefMI); - LIs->InsertMachineInstrInMaps(prior(RestorePt), RestoreIdx); + SlotIndex RematIdx = LIs->InsertMachineInstrInMaps(prior(RestorePt)); ReconstructLiveInterval(CurrLI); - SlotIndex RematIdx = LIs->getInstructionIndex(prior(RestorePt)); RematIdx = RematIdx.getDefIndex(); RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RematIdx)); @@ -1088,17 +1056,15 @@ } // Find a point to restore the value after the barrier. - SlotIndex RestoreIndex; MachineBasicBlock::iterator RestorePt = - findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB, RestoreIndex); + findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB); if (RestorePt == BarrierMBB->end()) { DEBUG(errs() << "FAILED (could not find a suitable restore point).\n"); return false; } if (DefMI && LIs->isReMaterializable(*LI, ValNo, DefMI)) - if (Rematerialize(LI->reg, ValNo, DefMI, RestorePt, - RestoreIndex, RefsInMBB)) { + if (Rematerialize(LI->reg, ValNo, DefMI, RestorePt, RefsInMBB)) { DEBUG(errs() << "success (remat).\n"); return true; } @@ -1116,7 +1082,7 @@ SpillIndex = LIs->getInstructionIndex(SpillMI); } else { MachineBasicBlock::iterator SpillPt = - findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB, SpillIndex); + findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB); if (SpillPt == BarrierMBB->begin()) { DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. @@ -1126,10 +1092,10 @@ SS = CreateSpillStackSlot(CurrLI->reg, RC); TII->storeRegToStackSlot(*BarrierMBB, SpillPt, CurrLI->reg, true, SS, RC); SpillMI = prior(SpillPt); - LIs->InsertMachineInstrInMaps(SpillMI, SpillIndex); + SpillIndex = LIs->InsertMachineInstrInMaps(SpillMI); } } else if (!IsAvailableInStack(DefMBB, CurrLI->reg, ValNo->def, - RestoreIndex, SpillIndex, SS)) { + LIs->getZeroIndex(), SpillIndex, SS)) { // If it's already split, just restore the value. There is no need to spill // the def again. if (!DefMI) { @@ -1146,13 +1112,13 @@ if (DefMBB == BarrierMBB) { // Add spill after the def and the last use before the barrier. SpillPt = findSpillPoint(BarrierMBB, Barrier, DefMI, - RefsInMBB, SpillIndex); + RefsInMBB); if (SpillPt == DefMBB->begin()) { DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. } } else { - SpillPt = findNextEmptySlot(DefMBB, DefMI, SpillIndex); + SpillPt = next(MachineBasicBlock::iterator(DefMI)); if (SpillPt == DefMBB->end()) { DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. @@ -1162,7 +1128,7 @@ SS = CreateSpillStackSlot(CurrLI->reg, RC); TII->storeRegToStackSlot(*DefMBB, SpillPt, CurrLI->reg, false, SS, RC); SpillMI = prior(SpillPt); - LIs->InsertMachineInstrInMaps(SpillMI, SpillIndex); + SpillIndex = LIs->InsertMachineInstrInMaps(SpillMI); } } @@ -1172,6 +1138,7 @@ // Add restore. bool FoldedRestore = false; + SlotIndex RestoreIndex; if (MachineInstr* LMI = FoldRestore(CurrLI->reg, RC, Barrier, BarrierMBB, SS, RefsInMBB)) { RestorePt = LMI; @@ -1180,7 +1147,7 @@ } else { TII->loadRegFromStackSlot(*BarrierMBB, RestorePt, CurrLI->reg, SS, RC); MachineInstr *LoadMI = prior(RestorePt); - LIs->InsertMachineInstrInMaps(LoadMI, RestoreIndex); + RestoreIndex = LIs->InsertMachineInstrInMaps(LoadMI); } // Update spill stack slot live interval. Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=88725&r1=88724&r2=88725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Fri Nov 13 18:02:51 2009 @@ -156,7 +156,7 @@ return false; } -void SlotIndexes::renumber() { +void SlotIndexes::renumberIndexes() { // Renumber updates the index of every element of the index list. // If all instrs in the function have been allocated an index (which has been @@ -184,7 +184,6 @@ Slots = 1; index += (Slots + 1) * SlotIndex::NUM; - } } } Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=88725&r1=88724&r2=88725&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Fri Nov 13 18:02:51 2009 @@ -52,16 +52,16 @@ /// Ensures there is space before the given machine instruction, returns the /// instruction's new number. SlotIndex makeSpaceBefore(MachineInstr *mi) { - if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { + //if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { // FIXME: Should be updated to use rewrite-in-place methods when they're // introduced. Currently broken. //lis->scaleNumbering(2); //ls->scaleNumbering(2); - } + //} SlotIndex miIdx = lis->getInstructionIndex(mi); - assert(lis->hasGapBeforeInstr(miIdx)); + //assert(lis->hasGapBeforeInstr(miIdx)); return miIdx; } @@ -69,16 +69,16 @@ /// Ensure there is space after the given machine instruction, returns the /// instruction's new number. SlotIndex makeSpaceAfter(MachineInstr *mi) { - if (!lis->hasGapAfterInstr(lis->getInstructionIndex(mi))) { + //if (!lis->hasGapAfterInstr(lis->getInstructionIndex(mi))) { // FIXME: Should be updated to use rewrite-in-place methods when they're // introduced. Currently broken. // lis->scaleNumbering(2); // ls->scaleNumbering(2); - } + //} SlotIndex miIdx = lis->getInstructionIndex(mi); - assert(lis->hasGapAfterInstr(miIdx)); + //assert(lis->hasGapAfterInstr(miIdx)); return miIdx; } @@ -99,14 +99,8 @@ true, ss, trc); MachineBasicBlock::iterator storeInstItr(next(mi)); MachineInstr *storeInst = &*storeInstItr; - SlotIndex storeInstIdx = miIdx.getNextIndex(); - - assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && - "Store inst index already in use."); - lis->InsertMachineInstrInMaps(storeInst, storeInstIdx); - - return storeInstIdx; + return lis->InsertMachineInstrInMaps(storeInst); } /// Insert a store of the given vreg to the given stack slot immediately @@ -120,14 +114,8 @@ tii->storeRegToStackSlot(*mi->getParent(), mi, vreg, true, ss, trc); MachineBasicBlock::iterator storeInstItr(prior(mi)); MachineInstr *storeInst = &*storeInstItr; - SlotIndex storeInstIdx = miIdx.getPrevIndex(); - - assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && - "Store inst index already in use."); - lis->InsertMachineInstrInMaps(storeInst, storeInstIdx); - - return storeInstIdx; + return lis->InsertMachineInstrInMaps(storeInst); } void insertStoreAfterInstOnInterval(LiveInterval *li, @@ -164,14 +152,8 @@ tii->loadRegFromStackSlot(*mi->getParent(), nextInstItr, vreg, ss, trc); MachineBasicBlock::iterator loadInstItr(next(mi)); MachineInstr *loadInst = &*loadInstItr; - SlotIndex loadInstIdx = miIdx.getNextIndex(); - - assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && - "Store inst index already in use."); - lis->InsertMachineInstrInMaps(loadInst, loadInstIdx); - - return loadInstIdx; + return lis->InsertMachineInstrInMaps(loadInst); } /// Insert a load of the given vreg from the given stack slot immediately @@ -186,14 +168,8 @@ tii->loadRegFromStackSlot(*mi->getParent(), mi, vreg, ss, trc); MachineBasicBlock::iterator loadInstItr(prior(mi)); MachineInstr *loadInst = &*loadInstItr; - SlotIndex loadInstIdx = miIdx.getPrevIndex(); - - assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && - "Load inst index already in use."); - - lis->InsertMachineInstrInMaps(loadInst, loadInstIdx); - return loadInstIdx; + return lis->InsertMachineInstrInMaps(loadInst); } void insertLoadBeforeInstOnInterval(LiveInterval *li, From stoklund at 2pi.dk Fri Nov 13 18:38:06 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 14 Nov 2009 00:38:06 -0000 Subject: [llvm-commits] [llvm] r88727 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp Message-ID: <200911140038.nAE0c6w1028544@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 18:38:06 2009 New Revision: 88727 URL: http://llvm.org/viewvc/llvm-project?rev=88727&view=rev Log: Update MachineDominator information Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=88727&r1=88726&r2=88727&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri Nov 13 18:38:06 2009 @@ -17,7 +17,7 @@ #include "PHIElimination.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -49,12 +49,12 @@ void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved(); + AU.addPreserved(); if (SplitEdges) { AU.addRequired(); } else { AU.setPreservesCFG(); AU.addPreservedID(MachineLoopInfoID); - AU.addPreservedID(MachineDominatorsID); } MachineFunctionPass::getAnalysisUsage(AU); } @@ -297,7 +297,6 @@ // Okay, if we now know that the value is not live out of the block, we can // add a kill marker in this block saying that it kills the incoming value! - // When SplitEdges is enabled, the value is never live out. if (!ValueIsUsed && !isLiveOut(SrcReg, opBlock, *LV)) { // In our final twist, we have to decide which instruction kills the // register. In most cases this is the copy, however, the first @@ -443,14 +442,18 @@ SmallVector Cond; MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); - if (LiveVariables *LV = getAnalysisIfAvailable()) - LV->addNewBlock(NMBB, A); - // Fix PHI nodes in B so they refer to NMBB instead of A for (MachineBasicBlock::iterator i = B->begin(), e = B->end(); i != e && i->getOpcode() == TargetInstrInfo::PHI; ++i) for (unsigned ni = 1, ne = i->getNumOperands(); ni != ne; ni += 2) if (i->getOperand(ni+1).getMBB() == A) i->getOperand(ni+1).setMBB(NMBB); + + if (LiveVariables *LV=getAnalysisIfAvailable()) + LV->addNewBlock(NMBB, A); + + if (MachineDominatorTree *MDT=getAnalysisIfAvailable()) + MDT->addNewBlock(NMBB, A); + return NMBB; } From stoklund at 2pi.dk Fri Nov 13 18:38:13 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 14 Nov 2009 00:38:13 -0000 Subject: [llvm-commits] [llvm] r88728 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp Message-ID: <200911140038.nAE0cDc4028558@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 13 18:38:13 2009 New Revision: 88728 URL: http://llvm.org/viewvc/llvm-project?rev=88728&view=rev Log: Fix bug in -split-phi-edges. When splitting an edge after a machine basic block with fall-through, we forgot to insert a jump instruction. Fix this by calling updateTerminator() on the fall-through block when relevant. Also be more precise in PHIElimination::isLiveIn. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=88728&r1=88727&r2=88728&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri Nov 13 18:38:13 2009 @@ -64,7 +64,6 @@ PHIDefs.clear(); PHIKills.clear(); - bool Changed = false; // Split critical edges to help the coalescer @@ -419,7 +418,16 @@ LiveVariables &LV) { LiveVariables::VarInfo &VI = LV.getVarInfo(Reg); - return VI.AliveBlocks.test(MBB.getNumber()) || VI.findKill(&MBB); + if (VI.AliveBlocks.test(MBB.getNumber())) + return true; + + // defined in MBB? + const MachineInstr *Def = MRI->getVRegDef(Reg); + if (Def && Def->getParent() == &MBB) + return false; + + // killed in MBB? + return VI.findKill(&MBB); } MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, @@ -436,9 +444,12 @@ << " -- BB#" << B->getNumber() << '\n'); A->ReplaceUsesOfBlockWith(B, NMBB); - NMBB->addSuccessor(B); + // If A may fall through to B, we may have to insert a branch. + if (A->isLayoutSuccessor(B)) + A->updateTerminator(); // Insert unconditional "jump B" instruction in NMBB. + NMBB->addSuccessor(B); SmallVector Cond; MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); From evan.cheng at apple.com Fri Nov 13 19:50:00 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 01:50:00 -0000 Subject: [llvm-commits] [llvm] r88734 - in /llvm/trunk: lib/Target/ARM/ARMLoadStoreOptimizer.cpp test/CodeGen/Thumb2/2009-11-13-STRDBug.ll Message-ID: <200911140150.nAE1o1OI030882@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 19:50:00 2009 New Revision: 88734 URL: http://llvm.org/viewvc/llvm-project?rev=88734&view=rev Log: When expanding t2STRDi8 r, r to two stores, add kill markers correctly. Added: llvm/trunk/test/CodeGen/Thumb2/2009-11-13-STRDBug.ll Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=88734&r1=88733&r2=88734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Fri Nov 13 19:50:00 2009 @@ -866,6 +866,13 @@ BaseReg, BaseKill, BaseUndef, OffReg, OffKill, OffUndef, Pred, PredReg, TII, isT2); } else { + if (OddReg == EvenReg && EvenDeadKill) { + // If the two source operands are the same, the kill marker is probably + // on the first one. e.g. + // t2STRDi8 %R5, %R5, %R9, 0, 14, %reg0 + EvenDeadKill = false; + OddDeadKill = true; + } InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenDeadKill, EvenUndef, BaseReg, false, BaseUndef, OffReg, false, OffUndef, Added: llvm/trunk/test/CodeGen/Thumb2/2009-11-13-STRDBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-11-13-STRDBug.ll?rev=88734&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-11-13-STRDBug.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-11-13-STRDBug.ll Fri Nov 13 19:50:00 2009 @@ -0,0 +1,20 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 +; rdar://7394794 + +define arm_apcscc void @lshift_double(i64 %l1, i64 %h1, i64 %count, i32 %prec, i64* nocapture %lv, i64* nocapture %hv, i32 %arith) nounwind { +entry: + %..i = select i1 false, i64 0, i64 0 ; [#uses=1] + br i1 undef, label %bb11.i, label %bb6.i + +bb6.i: ; preds = %entry + %0 = lshr i64 %h1, 0 ; [#uses=1] + store i64 %0, i64* %hv, align 4 + %1 = lshr i64 %l1, 0 ; [#uses=1] + %2 = or i64 0, %1 ; [#uses=1] + store i64 %2, i64* %lv, align 4 + br label %bb11.i + +bb11.i: ; preds = %bb6.i, %entry + store i64 %..i, i64* %lv, align 4 + ret void +} From gohman at apple.com Fri Nov 13 20:06:30 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 14 Nov 2009 02:06:30 -0000 Subject: [llvm-commits] [llvm] r88737 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp test/CodeGen/X86/tailcall1.ll Message-ID: <200911140206.nAE26VGc031468@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 20:06:30 2009 New Revision: 88737 URL: http://llvm.org/viewvc/llvm-project?rev=88737&view=rev Log: Enable the tail call optimization when the caller returns undef. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/test/CodeGen/X86/tailcall1.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=88737&r1=88736&r2=88737&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Nov 13 20:06:30 2009 @@ -4376,6 +4376,10 @@ // what the call's return type is. if (!Ret || Ret->getNumOperands() == 0) return true; + // If the return value is undef, it doesn't matter what the call's + // return type is. + if (isa(Ret->getOperand(0))) return true; + // Conservatively require the attributes of the call to match those of // the return. Ignore noalias because it doesn't affect the call sequence. unsigned CallerRetAttr = F->getAttributes().getRetAttributes(); Modified: llvm/trunk/test/CodeGen/X86/tailcall1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tailcall1.ll?rev=88737&r1=88736&r2=88737&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tailcall1.ll (original) +++ llvm/trunk/test/CodeGen/X86/tailcall1.ll Fri Nov 13 20:06:30 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -tailcallopt | grep TAILCALL | count 3 +; RUN: llc < %s -march=x86 -tailcallopt | grep TAILCALL | count 4 define fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { entry: ret i32 %a3 @@ -23,3 +23,10 @@ %p = tail call fastcc noalias i8* @noalias_callee() ret i8* %p } + +declare fastcc i32 @i32_callee() + +define fastcc i32 @ret_undef() nounwind { + %p = tail call fastcc i32 @i32_callee() + ret i32 undef +} From evan.cheng at apple.com Fri Nov 13 20:09:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 02:09:10 -0000 Subject: [llvm-commits] [llvm] r88738 - in /llvm/trunk: lib/CodeGen/VirtRegRewriter.cpp test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Message-ID: <200911140209.nAE29All031547@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 20:09:09 2009 New Revision: 88738 URL: http://llvm.org/viewvc/llvm-project?rev=88738&view=rev Log: Fix PR5412: Fix an inverted check and another missing sub-register check. Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=88738&r1=88737&r2=88738&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Fri Nov 13 20:09:09 2009 @@ -483,19 +483,20 @@ } /// InvalidateRegDef - If the def operand of the specified def MI is now dead -/// (since it's spill instruction is removed), mark it isDead. Also checks if +/// (since its spill instruction is removed), mark it isDead. Also checks if /// the def MI has other definition operands that are not dead. Returns it by /// reference. static bool InvalidateRegDef(MachineBasicBlock::iterator I, MachineInstr &NewDef, unsigned Reg, - bool &HasLiveDef) { + bool &HasLiveDef, + const TargetRegisterInfo *TRI) { // Due to remat, it's possible this reg isn't being reused. That is, // the def of this reg (by prev MI) is now dead. MachineInstr *DefMI = I; MachineOperand *DefOp = NULL; for (unsigned i = 0, e = DefMI->getNumOperands(); i != e; ++i) { MachineOperand &MO = DefMI->getOperand(i); - if (!MO.isReg() || !MO.isUse() || !MO.isKill() || MO.isUndef()) + if (!MO.isReg() || !MO.isDef() || !MO.isKill() || MO.isUndef()) continue; if (MO.getReg() == Reg) DefOp = &MO; @@ -512,7 +513,8 @@ MachineInstr *NMI = I; for (unsigned j = 0, ee = NMI->getNumOperands(); j != ee; ++j) { MachineOperand &MO = NMI->getOperand(j); - if (!MO.isReg() || MO.getReg() != Reg) + if (!MO.isReg() || MO.getReg() == 0 || + (MO.getReg() != Reg && !TRI->isSubRegister(Reg, MO.getReg()))) continue; if (MO.isUse()) FoundUse = true; @@ -556,11 +558,30 @@ KillOps[*SR] = NULL; RegKills.reset(*SR); } - - if (!MI.isRegTiedToDefOperand(i)) - // Unless it's a two-address operand, this is the new kill. - MO.setIsKill(); + } else { + // Check for subreg kills as well. + // d4 = + // store d4, fi#0 + // ... + // = s8 + // ... + // = d4 + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) { + unsigned SReg = *SR; + if (RegKills[SReg] && KillOps[SReg]->getParent() != &MI) { + KillOps[SReg]->setIsKill(false); + unsigned KReg = KillOps[SReg]->getReg(); + KillOps[KReg] = NULL; + RegKills.reset(KReg); + + for (const unsigned *SSR = TRI->getSubRegisters(KReg); *SSR; ++SSR) { + KillOps[*SSR] = NULL; + RegKills.reset(*SSR); + } + } + } } + if (MO.isKill()) { RegKills.set(Reg); KillOps[Reg] = &MO; @@ -1458,7 +1479,7 @@ // being reused. for (unsigned j = 0, ee = KillRegs.size(); j != ee; ++j) { bool HasOtherDef = false; - if (InvalidateRegDef(PrevMII, *MII, KillRegs[j], HasOtherDef)) { + if (InvalidateRegDef(PrevMII, *MII, KillRegs[j], HasOtherDef, TRI)) { MachineInstr *DeadDef = PrevMII; if (ReMatDefs.count(DeadDef) && !HasOtherDef) { // FIXME: This assumes a remat def does not have side effects. Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll?rev=88738&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-13-ScavengerAssert2.ll Fri Nov 13 20:09:09 2009 @@ -0,0 +1,123 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s +; PR5412 + +%bar = type { %quad, float, float, [3 x %quuz*], [3 x %bar*], [2 x %bar*], [3 x i8], i8 } +%baz = type { %bar*, i32 } +%foo = type { i8, %quux, %quad, float, [64 x %quuz], [128 x %bar], i32, %baz, %baz } +%quad = type { [4 x float] } +%quux = type { [4 x %quuz*], [4 x float], i32 } +%quuz = type { %quad, %quad } + +define arm_aapcs_vfpcc %bar* @aaa(%foo* nocapture %this, %quuz* %a, %quuz* %b, %quuz* %c, i8 zeroext %forced) { +entry: + br i1 undef, label %bb85, label %bb + +bb: ; preds = %entry + br i1 undef, label %bb3.i, label %bb2.i + +bb2.i: ; preds = %bb + br label %bb3.i + +bb3.i: ; preds = %bb2.i, %bb + %0 = getelementptr inbounds %quuz* %a, i32 0, i32 1, i32 0, i32 0 ; [#uses=0] + %1 = fsub float 0.000000e+00, undef ; [#uses=1] + %2 = getelementptr inbounds %quuz* %b, i32 0, i32 1, i32 0, i32 1 ; [#uses=2] + %3 = load float* %2, align 4 ; [#uses=1] + %4 = getelementptr inbounds %quuz* %a, i32 0, i32 1, i32 0, i32 1 ; [#uses=1] + %5 = fsub float %3, undef ; [#uses=2] + %6 = getelementptr inbounds %quuz* %b, i32 0, i32 1, i32 0, i32 2 ; [#uses=2] + %7 = load float* %6, align 4 ; [#uses=1] + %8 = fsub float %7, undef ; [#uses=1] + %9 = getelementptr inbounds %quuz* %c, i32 0, i32 1, i32 0, i32 0 ; [#uses=2] + %10 = load float* %9, align 4 ; [#uses=1] + %11 = fsub float %10, undef ; [#uses=2] + %12 = getelementptr inbounds %quuz* %c, i32 0, i32 1, i32 0, i32 1 ; [#uses=2] + %13 = load float* %12, align 4 ; [#uses=1] + %14 = fsub float %13, undef ; [#uses=1] + %15 = load float* undef, align 4 ; [#uses=1] + %16 = fsub float %15, undef ; [#uses=1] + %17 = fmul float %5, %16 ; [#uses=1] + %18 = fsub float %17, 0.000000e+00 ; [#uses=5] + %19 = fmul float %8, %11 ; [#uses=1] + %20 = fsub float %19, undef ; [#uses=3] + %21 = fmul float %1, %14 ; [#uses=1] + %22 = fmul float %5, %11 ; [#uses=1] + %23 = fsub float %21, %22 ; [#uses=2] + store float %18, float* undef + %24 = getelementptr inbounds %bar* null, i32 0, i32 0, i32 0, i32 1 ; [#uses=2] + store float %20, float* %24 + store float %23, float* undef + %25 = getelementptr inbounds %bar* null, i32 0, i32 0, i32 0, i32 3 ; [#uses=0] + %26 = fmul float %18, %18 ; [#uses=1] + %27 = fadd float %26, undef ; [#uses=1] + %28 = fadd float %27, undef ; [#uses=1] + %29 = call arm_aapcs_vfpcc float @sqrtf(float %28) readnone ; [#uses=1] + %30 = load float* null, align 4 ; [#uses=2] + %31 = load float* %4, align 4 ; [#uses=2] + %32 = load float* %2, align 4 ; [#uses=2] + %33 = load float* null, align 4 ; [#uses=3] + %34 = load float* %6, align 4 ; [#uses=2] + %35 = fsub float %33, %34 ; [#uses=2] + %36 = fmul float %20, %35 ; [#uses=1] + %37 = fsub float %36, undef ; [#uses=1] + %38 = fmul float %23, 0.000000e+00 ; [#uses=1] + %39 = fmul float %18, %35 ; [#uses=1] + %40 = fsub float %38, %39 ; [#uses=1] + %41 = fmul float %18, 0.000000e+00 ; [#uses=1] + %42 = fmul float %20, 0.000000e+00 ; [#uses=1] + %43 = fsub float %41, %42 ; [#uses=1] + %44 = fmul float 0.000000e+00, %37 ; [#uses=1] + %45 = fmul float %31, %40 ; [#uses=1] + %46 = fadd float %44, %45 ; [#uses=1] + %47 = fmul float %33, %43 ; [#uses=1] + %48 = fadd float %46, %47 ; [#uses=2] + %49 = load float* %9, align 4 ; [#uses=2] + %50 = fsub float %30, %49 ; [#uses=1] + %51 = load float* %12, align 4 ; [#uses=3] + %52 = fsub float %32, %51 ; [#uses=2] + %53 = load float* undef, align 4 ; [#uses=2] + %54 = load float* %24, align 4 ; [#uses=2] + %55 = fmul float %54, undef ; [#uses=1] + %56 = fmul float undef, %52 ; [#uses=1] + %57 = fsub float %55, %56 ; [#uses=1] + %58 = fmul float undef, %52 ; [#uses=1] + %59 = fmul float %54, %50 ; [#uses=1] + %60 = fsub float %58, %59 ; [#uses=1] + %61 = fmul float %30, %57 ; [#uses=1] + %62 = fmul float %32, 0.000000e+00 ; [#uses=1] + %63 = fadd float %61, %62 ; [#uses=1] + %64 = fmul float %34, %60 ; [#uses=1] + %65 = fadd float %63, %64 ; [#uses=2] + %66 = fcmp olt float %48, %65 ; [#uses=1] + %67 = fsub float %49, 0.000000e+00 ; [#uses=1] + %68 = fsub float %51, %31 ; [#uses=1] + %69 = fsub float %53, %33 ; [#uses=1] + %70 = fmul float undef, %67 ; [#uses=1] + %71 = load float* undef, align 4 ; [#uses=2] + %72 = fmul float %71, %69 ; [#uses=1] + %73 = fsub float %70, %72 ; [#uses=1] + %74 = fmul float %71, %68 ; [#uses=1] + %75 = fsub float %74, 0.000000e+00 ; [#uses=1] + %76 = fmul float %51, %73 ; [#uses=1] + %77 = fadd float undef, %76 ; [#uses=1] + %78 = fmul float %53, %75 ; [#uses=1] + %79 = fadd float %77, %78 ; [#uses=1] + %80 = select i1 %66, float %48, float %65 ; [#uses=1] + %81 = select i1 undef, float %80, float %79 ; [#uses=1] + %iftmp.164.0 = select i1 undef, float %29, float 1.000000e+00 ; [#uses=1] + %82 = fdiv float %81, %iftmp.164.0 ; [#uses=1] + %iftmp.165.0 = select i1 undef, float %82, float 0.000000e+00 ; [#uses=1] + store float %iftmp.165.0, float* undef, align 4 + br i1 false, label %bb4.i97, label %ccc.exit98 + +bb4.i97: ; preds = %bb3.i + br label %ccc.exit98 + +ccc.exit98: ; preds = %bb4.i97, %bb3.i + ret %bar* null + +bb85: ; preds = %entry + ret %bar* null +} + +declare arm_aapcs_vfpcc float @sqrtf(float) readnone Added: llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll?rev=88738&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Fri Nov 13 20:09:09 2009 @@ -0,0 +1,112 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s +; PR5412 + +%bar = type { %quad, float, float, [3 x %quuz*], [3 x %bar*], [2 x %bar*], [3 x i8], i8 } +%baz = type { %bar*, i32 } +%foo = type { i8, %quux, %quad, float, [64 x %quuz], [128 x %bar], i32, %baz, %baz } +%quad = type { [4 x float] } +%quux = type { [4 x %quuz*], [4 x float], i32 } +%quuz = type { %quad, %quad } + +define arm_aapcs_vfpcc %bar* @aaa(%foo* nocapture %this, %quuz* %a, %quuz* %b, %quuz* %c, i8 zeroext %forced) { +entry: + %0 = load %bar** undef, align 4 ; <%bar*> [#uses=2] + br i1 false, label %bb85, label %bb + +bb: ; preds = %entry + br i1 undef, label %bb3.i, label %bb2.i + +bb2.i: ; preds = %bb + br label %bb3.i + +bb3.i: ; preds = %bb2.i, %bb + %1 = getelementptr inbounds %quuz* %a, i32 0, i32 1, i32 0, i32 0 ; [#uses=1] + %2 = fsub float 0.000000e+00, undef ; [#uses=1] + %3 = getelementptr inbounds %quuz* %b, i32 0, i32 1, i32 0, i32 1 ; [#uses=1] + %4 = getelementptr inbounds %quuz* %b, i32 0, i32 1, i32 0, i32 2 ; [#uses=1] + %5 = fsub float 0.000000e+00, undef ; [#uses=1] + %6 = getelementptr inbounds %quuz* %c, i32 0, i32 1, i32 0, i32 0 ; [#uses=1] + %7 = getelementptr inbounds %quuz* %c, i32 0, i32 1, i32 0, i32 1 ; [#uses=1] + %8 = fsub float undef, undef ; [#uses=1] + %9 = fmul float 0.000000e+00, %8 ; [#uses=1] + %10 = fmul float %5, 0.000000e+00 ; [#uses=1] + %11 = fsub float %9, %10 ; [#uses=3] + %12 = fmul float %2, 0.000000e+00 ; [#uses=1] + %13 = fmul float 0.000000e+00, undef ; [#uses=1] + %14 = fsub float %12, %13 ; [#uses=2] + store float %14, float* undef + %15 = getelementptr inbounds %bar* %0, i32 0, i32 0, i32 0, i32 3 ; [#uses=1] + store float 0.000000e+00, float* %15 + %16 = fmul float %11, %11 ; [#uses=1] + %17 = fadd float %16, 0.000000e+00 ; [#uses=1] + %18 = fadd float %17, undef ; [#uses=1] + %19 = call arm_aapcs_vfpcc float @sqrtf(float %18) readnone ; [#uses=2] + %20 = fcmp ogt float %19, 0x3F1A36E2E0000000 ; [#uses=1] + %21 = load float* %1, align 4 ; [#uses=2] + %22 = load float* %3, align 4 ; [#uses=2] + %23 = load float* undef, align 4 ; [#uses=2] + %24 = load float* %4, align 4 ; [#uses=2] + %25 = fsub float %23, %24 ; [#uses=2] + %26 = fmul float 0.000000e+00, %25 ; [#uses=1] + %27 = fsub float %26, undef ; [#uses=1] + %28 = fmul float %14, 0.000000e+00 ; [#uses=1] + %29 = fmul float %11, %25 ; [#uses=1] + %30 = fsub float %28, %29 ; [#uses=1] + %31 = fsub float undef, 0.000000e+00 ; [#uses=1] + %32 = fmul float %21, %27 ; [#uses=1] + %33 = fmul float undef, %30 ; [#uses=1] + %34 = fadd float %32, %33 ; [#uses=1] + %35 = fmul float %23, %31 ; [#uses=1] + %36 = fadd float %34, %35 ; [#uses=1] + %37 = load float* %6, align 4 ; [#uses=2] + %38 = load float* %7, align 4 ; [#uses=2] + %39 = fsub float %22, %38 ; [#uses=2] + %40 = load float* undef, align 4 ; [#uses=1] + %41 = load float* null, align 4 ; [#uses=2] + %42 = fmul float %41, undef ; [#uses=1] + %43 = fmul float undef, %39 ; [#uses=1] + %44 = fsub float %42, %43 ; [#uses=1] + %45 = fmul float undef, %39 ; [#uses=1] + %46 = fmul float %41, 0.000000e+00 ; [#uses=1] + %47 = fsub float %45, %46 ; [#uses=1] + %48 = fmul float 0.000000e+00, %44 ; [#uses=1] + %49 = fmul float %22, undef ; [#uses=1] + %50 = fadd float %48, %49 ; [#uses=1] + %51 = fmul float %24, %47 ; [#uses=1] + %52 = fadd float %50, %51 ; [#uses=1] + %53 = fsub float %37, %21 ; [#uses=2] + %54 = fmul float undef, undef ; [#uses=1] + %55 = fmul float undef, undef ; [#uses=1] + %56 = fsub float %54, %55 ; [#uses=1] + %57 = fmul float undef, %53 ; [#uses=1] + %58 = load float* undef, align 4 ; [#uses=2] + %59 = fmul float %58, undef ; [#uses=1] + %60 = fsub float %57, %59 ; [#uses=1] + %61 = fmul float %58, undef ; [#uses=1] + %62 = fmul float undef, %53 ; [#uses=1] + %63 = fsub float %61, %62 ; [#uses=1] + %64 = fmul float %37, %56 ; [#uses=1] + %65 = fmul float %38, %60 ; [#uses=1] + %66 = fadd float %64, %65 ; [#uses=1] + %67 = fmul float %40, %63 ; [#uses=1] + %68 = fadd float %66, %67 ; [#uses=1] + %69 = select i1 undef, float %36, float %52 ; [#uses=1] + %70 = select i1 undef, float %69, float %68 ; [#uses=1] + %iftmp.164.0 = select i1 %20, float %19, float 1.000000e+00 ; [#uses=1] + %71 = fdiv float %70, %iftmp.164.0 ; [#uses=1] + store float %71, float* null, align 4 + %72 = icmp eq %bar* null, %0 ; [#uses=1] + br i1 %72, label %bb4.i97, label %ccc.exit98 + +bb4.i97: ; preds = %bb3.i + %73 = load %bar** undef, align 4 ; <%bar*> [#uses=0] + br label %ccc.exit98 + +ccc.exit98: ; preds = %bb4.i97, %bb3.i + ret %bar* null + +bb85: ; preds = %entry + ret %bar* null +} + +declare arm_aapcs_vfpcc float @sqrtf(float) readnone From evan.cheng at apple.com Fri Nov 13 20:11:33 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 02:11:33 -0000 Subject: [llvm-commits] [llvm] r88739 - /llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Message-ID: <200911140211.nAE2BXoH031645@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 20:11:32 2009 New Revision: 88739 URL: http://llvm.org/viewvc/llvm-project?rev=88739&view=rev Log: Add radar number. Modified: llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Modified: llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll?rev=88739&r1=88738&r2=88739&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-11-13-VRRewriterCrash.ll Fri Nov 13 20:11:32 2009 @@ -1,5 +1,6 @@ ; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s ; PR5412 +; rdar://7384107 %bar = type { %quad, float, float, [3 x %quuz*], [3 x %bar*], [2 x %bar*], [3 x i8], i8 } %baz = type { %bar*, i32 } From gohman at apple.com Fri Nov 13 20:27:52 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 14 Nov 2009 02:27:52 -0000 Subject: [llvm-commits] [llvm] r88742 - in /llvm/trunk: include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/GVN.cpp Message-ID: <200911140227.nAE2Rqbm032273@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 13 20:27:51 2009 New Revision: 88742 URL: http://llvm.org/viewvc/llvm-project?rev=88742&view=rev Log: Add an option for running GVN with redundant load processing disabled. Modified: llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=88742&r1=88741&r2=88742&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Fri Nov 13 20:27:51 2009 @@ -263,7 +263,7 @@ // GVN - This pass performs global value numbering and redundant load // elimination cotemporaneously. // -FunctionPass *createGVNPass(bool NoPRE = false); +FunctionPass *createGVNPass(bool NoPRE = false, bool NoLoads = false); //===----------------------------------------------------------------------===// // Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=88742&r1=88741&r2=88742&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Nov 13 20:27:51 2009 @@ -443,6 +443,11 @@ valueNumbering[C] = e; return e; } + if (!MD) { + e = nextValueNumber++; + valueNumbering[C] = e; + return e; + } MemDepResult local_dep = MD->getDependency(C); @@ -669,10 +674,12 @@ bool runOnFunction(Function &F); public: static char ID; // Pass identification, replacement for typeid - GVN(bool nopre = false) : FunctionPass(&ID), NoPRE(nopre) { } + explicit GVN(bool nopre = false, bool noloads = false) + : FunctionPass(&ID), NoPRE(nopre), NoLoads(noloads), MD(0) { } private: bool NoPRE; + bool NoLoads; MemoryDependenceAnalysis *MD; DominatorTree *DT; @@ -682,7 +689,8 @@ // This transformation requires dominator postdominator info virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.addRequired(); + if (!NoLoads) + AU.addRequired(); AU.addRequired(); AU.addPreserved(); @@ -711,7 +719,9 @@ } // createGVNPass - The public interface to this file... -FunctionPass *llvm::createGVNPass(bool NoPRE) { return new GVN(NoPRE); } +FunctionPass *llvm::createGVNPass(bool NoPRE, bool NoLoads) { + return new GVN(NoPRE, NoLoads); +} static RegisterPass X("gvn", "Global Value Numbering"); @@ -1476,6 +1486,9 @@ /// processLoad - Attempt to eliminate a load, first by eliminating it /// locally, and then attempting non-local elimination if that fails. bool GVN::processLoad(LoadInst *L, SmallVectorImpl &toErase) { + if (!MD) + return false; + if (L->isVolatile()) return false; @@ -1686,7 +1699,7 @@ if (constVal) { p->replaceAllUsesWith(constVal); - if (isa(constVal->getType())) + if (MD && isa(constVal->getType())) MD->invalidateCachedPointerInfo(constVal); VN.erase(p); @@ -1707,7 +1720,7 @@ // Remove it! VN.erase(I); I->replaceAllUsesWith(repl); - if (isa(repl->getType())) + if (MD && isa(repl->getType())) MD->invalidateCachedPointerInfo(repl); toErase.push_back(I); return true; @@ -1721,7 +1734,8 @@ /// runOnFunction - This is the main transformation entry point for a function. bool GVN::runOnFunction(Function& F) { - MD = &getAnalysis(); + if (!NoLoads) + MD = &getAnalysis(); DT = &getAnalysis(); VN.setAliasAnalysis(&getAnalysis()); VN.setMemDep(MD); @@ -1793,7 +1807,7 @@ for (SmallVector::iterator I = toErase.begin(), E = toErase.end(); I != E; ++I) { DEBUG(errs() << "GVN removed: " << **I << '\n'); - MD->removeInstruction(*I); + if (MD) MD->removeInstruction(*I); (*I)->eraseFromParent(); DEBUG(verifyRemoved(*I)); } @@ -1946,12 +1960,12 @@ localAvail[CurrentBlock]->table[ValNo] = Phi; CurInst->replaceAllUsesWith(Phi); - if (isa(Phi->getType())) + if (MD && isa(Phi->getType())) MD->invalidateCachedPointerInfo(Phi); VN.erase(CurInst); DEBUG(errs() << "GVN PRE removed: " << *CurInst << '\n'); - MD->removeInstruction(CurInst); + if (MD) MD->removeInstruction(CurInst); CurInst->eraseFromParent(); DEBUG(verifyRemoved(CurInst)); Changed = true; From evan.cheng at apple.com Fri Nov 13 20:55:43 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 02:55:43 -0000 Subject: [llvm-commits] [llvm] r88745 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/CodeGen/TargetInstrInfoImpl.cpp lib/CodeGen/TwoAddressInstructionPass.cpp lib/CodeGen/VirtRegRewriter.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h lib/Target/ARM/ARMInstrInfo.cpp lib/Target/ARM/ARMInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Message-ID: <200911140255.nAE2tijh000675@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 20:55:43 2009 New Revision: 88745 URL: http://llvm.org/viewvc/llvm-project?rev=88745&view=rev Log: - Change TargetInstrInfo::reMaterialize to pass in TargetRegisterInfo. - If destination is a physical register and it has a subreg index, use the sub-register instead. This fixes PR5423. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Nov 13 20:55:43 2009 @@ -21,6 +21,7 @@ class MCAsmInfo; class TargetRegisterClass; +class TargetRegisterInfo; class LiveVariables; class CalleeSavedInfo; class SDNode; @@ -224,7 +225,8 @@ virtual void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const = 0; + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const = 0; /// convertToThreeAddress - This method must be implemented by targets that /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target @@ -554,7 +556,8 @@ virtual void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubReg, - const MachineInstr *Orig) const; + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const; virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other, const MachineRegisterInfo *MRI) const; Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Fri Nov 13 20:55:43 2009 @@ -881,7 +881,7 @@ if (KillPt == DefMI->getParent()->end()) return false; - TII->reMaterialize(MBB, RestorePt, VReg, 0, DefMI); + TII->reMaterialize(MBB, RestorePt, VReg, 0, DefMI, TRI); SlotIndex RematIdx = LIs->InsertMachineInstrInMaps(prior(RestorePt)); ReconstructLiveInterval(CurrLI); Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Fri Nov 13 20:55:43 2009 @@ -709,7 +709,7 @@ } MachineBasicBlock::iterator MII = next(MachineBasicBlock::iterator(CopyMI)); - tii_->reMaterialize(*MBB, MII, DstReg, DstSubIdx, DefMI); + tii_->reMaterialize(*MBB, MII, DstReg, DstSubIdx, DefMI, tri_); MachineInstr *NewMI = prior(MII); if (checkForDeadDef) { Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Fri Nov 13 20:55:43 2009 @@ -135,11 +135,16 @@ MachineBasicBlock::iterator I, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const { MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); MachineOperand &MO = MI->getOperand(0); - MO.setReg(DestReg); - MO.setSubReg(SubIdx); + if (TargetRegisterInfo::isVirtualRegister(DestReg)) { + MO.setReg(DestReg); + MO.setSubReg(SubIdx); + } else { + MO.setReg(TRI->getSubReg(DestReg, SubIdx)); + } MBB.insert(I, MI); } Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Fri Nov 13 20:55:43 2009 @@ -1033,7 +1033,7 @@ isProfitableToReMat(regB, rc, mi, DefMI, mbbi, Dist)){ DEBUG(errs() << "2addr: REMATTING : " << *DefMI << "\n"); unsigned regASubIdx = mi->getOperand(DstIdx).getSubReg(); - TII->reMaterialize(*mbbi, mi, regA, regASubIdx, DefMI); + TII->reMaterialize(*mbbi, mi, regA, regASubIdx, DefMI, TRI); ReMatRegs.set(regB); ++NumReMats; } else { Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Fri Nov 13 20:55:43 2009 @@ -594,7 +594,7 @@ for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI.getOperand(i); - if (!MO.isReg() || !MO.isDef()) + if (!MO.isReg() || !MO.getReg() || !MO.isDef()) continue; unsigned Reg = MO.getReg(); RegKills.reset(Reg); @@ -626,7 +626,7 @@ "Don't know how to remat instructions that define > 1 values!"); #endif TII->reMaterialize(MBB, MII, DestReg, - ReMatDefMI->getOperand(0).getSubReg(), ReMatDefMI); + ReMatDefMI->getOperand(0).getSubReg(), ReMatDefMI, TRI); MachineInstr *NewMI = prior(MII); for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { MachineOperand &MO = NewMI->getOperand(i); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Fri Nov 13 20:55:43 2009 @@ -921,8 +921,15 @@ reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const { DebugLoc dl = Orig->getDebugLoc(); + + if (SubIdx && TargetRegisterInfo::isPhysicalRegister(DestReg)) { + DestReg = TRI->getSubReg(DestReg, SubIdx); + SubIdx = 0; + } + unsigned Opcode = Orig->getOpcode(); switch (Opcode) { default: { Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Fri Nov 13 20:55:43 2009 @@ -267,7 +267,8 @@ virtual void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const; virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other, const MachineRegisterInfo *MRI) const; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Fri Nov 13 20:55:43 2009 @@ -81,8 +81,8 @@ void ARMInstrInfo:: reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { + unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const { DebugLoc dl = Orig->getDebugLoc(); unsigned Opcode = Orig->getOpcode(); switch (Opcode) { @@ -100,6 +100,6 @@ } } - return ARMBaseInstrInfo::reMaterialize(MBB, I, DestReg, SubIdx, Orig); + return ARMBaseInstrInfo::reMaterialize(MBB, I, DestReg, SubIdx, Orig, TRI); } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Fri Nov 13 20:55:43 2009 @@ -37,7 +37,8 @@ void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const; /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Nov 13 20:55:43 2009 @@ -991,12 +991,13 @@ void X86InstrInfo::reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const { DebugLoc DL = DebugLoc::getUnknownLoc(); if (I != MBB.end()) DL = I->getDebugLoc(); if (SubIdx && TargetRegisterInfo::isPhysicalRegister(DestReg)) { - DestReg = RI.getSubReg(DestReg, SubIdx); + DestReg = TRI->getSubReg(DestReg, SubIdx); SubIdx = 0; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Fri Nov 13 20:55:43 2009 @@ -482,7 +482,8 @@ AliasAnalysis *AA) const; void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; + const MachineInstr *Orig, + const TargetRegisterInfo *TRI) const; /// convertToThreeAddress - This method must be implemented by targets that /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target Modified: llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll?rev=88745&r1=88744&r2=88745&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Fri Nov 13 20:55:43 2009 @@ -1,5 +1,6 @@ ; RUN: llc -mcpu=cortex-a8 < %s | FileCheck %s -; XFAIL: * +; PR5423 + target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" target triple = "armv7-eabi" From evan.cheng at apple.com Fri Nov 13 21:42:17 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 03:42:17 -0000 Subject: [llvm-commits] [llvm] r88753 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/VirtRegRewriter.cpp test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <200911140342.nAE3gHvn002241@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 13 21:42:17 2009 New Revision: 88753 URL: http://llvm.org/viewvc/llvm-project?rev=88753&view=rev Log: Added getSubRegIndex(A,B) that returns subreg index of A to B. Use it to replace broken code in VirtRegRewriter. Added: llvm/trunk/test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=88753&r1=88752&r2=88753&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Fri Nov 13 21:42:17 2009 @@ -464,6 +464,11 @@ /// exist. virtual unsigned getSubReg(unsigned RegNo, unsigned Index) const = 0; + /// getSubRegIndex - For a given register pair, return the sub-register index + /// if they are second register is a sub-register of the second. Return zero + /// otherwise. + virtual unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const = 0; + /// getMatchingSuperReg - Return a super-register of the specified register /// Reg so its sub-register of index SubIdx is Reg. unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=88753&r1=88752&r2=88753&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Fri Nov 13 21:42:17 2009 @@ -841,11 +841,8 @@ "A reuse cannot be a virtual register"); if (PRRU != RealPhysRegUsed) { // What was the sub-register index? - unsigned SubReg; - for (SubIdx = 1; (SubReg = TRI->getSubReg(PRRU, SubIdx)); SubIdx++) - if (SubReg == RealPhysRegUsed) - break; - assert(SubReg == RealPhysRegUsed && + SubIdx = TRI->getSubRegIndex(PRRU, RealPhysRegUsed); + assert(SubIdx && "Operand physreg is not a sub-register of PhysRegUsed"); } Added: llvm/trunk/test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll?rev=88753&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-11-13-VirtRegRewriterBug.ll Fri Nov 13 21:42:17 2009 @@ -0,0 +1,133 @@ +; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic -disable-fp-elim +; rdar://7394770 + +%struct.JVTLib_100487 = type <{ i8 }> + +define i32 @_Z13JVTLib_10335613JVTLib_10266513JVTLib_100579S_S_S_jPhj(i16* nocapture %ResidualX_Array.0, %struct.JVTLib_100487* nocapture byval align 4 %xqp, i16* nocapture %ResidualL_Array.0, i16* %ResidualDCZ_Array.0, i16* nocapture %ResidualACZ_FOArray.0, i32 %useFRextDequant, i8* nocapture %JVTLib_103357, i32 %use_field_scan) ssp { +bb.nph: + %0 = shl i32 undef, 1 ; [#uses=2] + %mask133.masked.masked.masked.masked.masked.masked = or i640 undef, undef ; [#uses=1] + br label %bb + +bb: ; preds = %_ZL13JVTLib_105204PKsPK13JVTLib_105184PsPhjS5_j.exit, %bb.nph + br i1 undef, label %bb2, label %bb1 + +bb1: ; preds = %bb + br i1 undef, label %bb.i, label %bb1.i + +bb2: ; preds = %bb + unreachable + +bb.i: ; preds = %bb1 + br label %_ZL13JVTLib_105204PKsPK13JVTLib_105184PsPhjS5_j.exit + +bb1.i: ; preds = %bb1 + br label %_ZL13JVTLib_105204PKsPK13JVTLib_105184PsPhjS5_j.exit + +_ZL13JVTLib_105204PKsPK13JVTLib_105184PsPhjS5_j.exit: ; preds = %bb1.i, %bb.i + br i1 undef, label %bb5, label %bb + +bb5: ; preds = %_ZL13JVTLib_105204PKsPK13JVTLib_105184PsPhjS5_j.exit + %mask271.masked.masked.masked.masked.masked.masked.masked = or i256 0, undef ; [#uses=2] + %mask266.masked.masked.masked.masked.masked.masked = or i256 %mask271.masked.masked.masked.masked.masked.masked.masked, undef ; [#uses=1] + %mask241.masked = or i256 undef, undef ; [#uses=1] + %ins237 = or i256 undef, 0 ; [#uses=1] + br i1 undef, label %bb9, label %bb10 + +bb9: ; preds = %bb5 + br i1 undef, label %bb12.i, label %_ZL13JVTLib_105255PKsPK13JVTLib_105184Psj.exit + +bb12.i: ; preds = %bb9 + br label %_ZL13JVTLib_105255PKsPK13JVTLib_105184Psj.exit + +_ZL13JVTLib_105255PKsPK13JVTLib_105184Psj.exit: ; preds = %bb12.i, %bb9 + ret i32 undef + +bb10: ; preds = %bb5 + %1 = sext i16 undef to i32 ; [#uses=1] + %2 = sext i16 undef to i32 ; [#uses=1] + %3 = sext i16 undef to i32 ; [#uses=1] + %4 = sext i16 undef to i32 ; [#uses=1] + %5 = sext i16 undef to i32 ; [#uses=1] + %6 = sext i16 undef to i32 ; [#uses=1] + %tmp211 = lshr i256 %mask271.masked.masked.masked.masked.masked.masked.masked, 112 ; [#uses=0] + %7 = sext i16 undef to i32 ; [#uses=1] + %tmp208 = lshr i256 %mask266.masked.masked.masked.masked.masked.masked, 128 ; [#uses=1] + %tmp209 = trunc i256 %tmp208 to i16 ; [#uses=1] + %8 = sext i16 %tmp209 to i32 ; [#uses=1] + %9 = sext i16 undef to i32 ; [#uses=1] + %10 = sext i16 undef to i32 ; [#uses=1] + %tmp193 = lshr i256 %mask241.masked, 208 ; [#uses=1] + %tmp194 = trunc i256 %tmp193 to i16 ; [#uses=1] + %11 = sext i16 %tmp194 to i32 ; [#uses=1] + %tmp187 = lshr i256 %ins237, 240 ; [#uses=1] + %tmp188 = trunc i256 %tmp187 to i16 ; [#uses=1] + %12 = sext i16 %tmp188 to i32 ; [#uses=1] + %13 = add nsw i32 %4, %1 ; [#uses=1] + %14 = add nsw i32 %5, 0 ; [#uses=1] + %15 = add nsw i32 %6, %2 ; [#uses=1] + %16 = add nsw i32 %7, %3 ; [#uses=1] + %17 = add nsw i32 0, %8 ; [#uses=1] + %18 = add nsw i32 %11, %9 ; [#uses=1] + %19 = add nsw i32 0, %10 ; [#uses=1] + %20 = add nsw i32 %12, 0 ; [#uses=1] + %21 = add nsw i32 %17, %13 ; [#uses=2] + %22 = add nsw i32 %18, %14 ; [#uses=2] + %23 = add nsw i32 %19, %15 ; [#uses=2] + %24 = add nsw i32 %20, %16 ; [#uses=2] + %25 = add nsw i32 %22, %21 ; [#uses=2] + %26 = add nsw i32 %24, %23 ; [#uses=2] + %27 = sub i32 %21, %22 ; [#uses=1] + %28 = sub i32 %23, %24 ; [#uses=1] + %29 = add nsw i32 %26, %25 ; [#uses=1] + %30 = sub i32 %25, %26 ; [#uses=1] + %31 = sub i32 %27, %28 ; [#uses=1] + %32 = ashr i32 %29, 1 ; [#uses=2] + %33 = ashr i32 %30, 1 ; [#uses=2] + %34 = ashr i32 %31, 1 ; [#uses=2] + %35 = icmp sgt i32 %32, 32767 ; [#uses=1] + %o0_0.0.i = select i1 %35, i32 32767, i32 %32 ; [#uses=2] + %36 = icmp slt i32 %o0_0.0.i, -32768 ; [#uses=1] + %37 = icmp sgt i32 %33, 32767 ; [#uses=1] + %o1_0.0.i = select i1 %37, i32 32767, i32 %33 ; [#uses=2] + %38 = icmp slt i32 %o1_0.0.i, -32768 ; [#uses=1] + %39 = icmp sgt i32 %34, 32767 ; [#uses=1] + %o2_0.0.i = select i1 %39, i32 32767, i32 %34 ; [#uses=2] + %40 = icmp slt i32 %o2_0.0.i, -32768 ; [#uses=1] + %tmp101 = lshr i640 %mask133.masked.masked.masked.masked.masked.masked, 256 ; [#uses=1] + %41 = trunc i32 %o0_0.0.i to i16 ; [#uses=1] + %tmp358 = select i1 %36, i16 -32768, i16 %41 ; [#uses=2] + %42 = trunc i32 %o1_0.0.i to i16 ; [#uses=1] + %tmp347 = select i1 %38, i16 -32768, i16 %42 ; [#uses=1] + %43 = trunc i32 %o2_0.0.i to i16 ; [#uses=1] + %tmp335 = select i1 %40, i16 -32768, i16 %43 ; [#uses=1] + %44 = icmp sgt i16 %tmp358, -1 ; [#uses=2] + %..i24 = select i1 %44, i16 %tmp358, i16 undef ; [#uses=1] + %45 = icmp sgt i16 %tmp347, -1 ; [#uses=1] + %46 = icmp sgt i16 %tmp335, -1 ; [#uses=1] + %47 = zext i16 %..i24 to i32 ; [#uses=1] + %tmp = trunc i640 %tmp101 to i32 ; [#uses=1] + %48 = and i32 %tmp, 65535 ; [#uses=2] + %49 = mul i32 %47, %48 ; [#uses=1] + %50 = zext i16 undef to i32 ; [#uses=1] + %51 = mul i32 %50, %48 ; [#uses=1] + %52 = add i32 %49, %0 ; [#uses=1] + %53 = add i32 %51, %0 ; [#uses=1] + %54 = lshr i32 %52, undef ; [#uses=1] + %55 = lshr i32 %53, undef ; [#uses=1] + %56 = trunc i32 %54 to i16 ; [#uses=1] + %57 = trunc i32 %55 to i16 ; [#uses=1] + %vs16Out0_0.0.i = select i1 %44, i16 %56, i16 undef ; [#uses=1] + %vs16Out0_4.0.i = select i1 %45, i16 0, i16 undef ; [#uses=1] + %vs16Out1_0.0.i = select i1 %46, i16 %57, i16 undef ; [#uses=1] + br i1 undef, label %bb129.i, label %_ZL13JVTLib_105207PKsPK13JVTLib_105184Psj.exit + +bb129.i: ; preds = %bb10 + br label %_ZL13JVTLib_105207PKsPK13JVTLib_105184Psj.exit + +_ZL13JVTLib_105207PKsPK13JVTLib_105184Psj.exit: ; preds = %bb129.i, %bb10 + %58 = phi i16 [ %vs16Out0_4.0.i, %bb129.i ], [ undef, %bb10 ] ; [#uses=0] + %59 = phi i16 [ undef, %bb129.i ], [ %vs16Out1_0.0.i, %bb10 ] ; [#uses=0] + store i16 %vs16Out0_0.0.i, i16* %ResidualDCZ_Array.0, align 2 + unreachable +} Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=88753&r1=88752&r2=88753&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Fri Nov 13 21:42:17 2009 @@ -66,6 +66,7 @@ << " virtual bool needsStackRealignment(const MachineFunction &) const\n" << " { return false; }\n" << " unsigned getSubReg(unsigned RegNo, unsigned Index) const;\n" + << " unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;\n" << "};\n\n"; const std::vector &RegisterClasses = @@ -831,6 +832,23 @@ OS << " };\n"; OS << " return 0;\n"; OS << "}\n\n"; + + OS << "unsigned " << ClassName + << "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n" + << " switch (RegNo) {\n" + << " default:\n return 0;\n"; + for (std::map > >::iterator + I = SubRegVectors.begin(), E = SubRegVectors.end(); I != E; ++I) { + OS << " case " << getQualifiedName(I->first) << ":\n"; + for (unsigned i = 0, e = I->second.size(); i != e; ++i) + OS << " if (SubRegNo == " + << getQualifiedName((I->second)[i].second) + << ") return " << (I->second)[i].first << ";\n"; + OS << " return 0;\n"; + } + OS << " };\n"; + OS << " return 0;\n"; + OS << "}\n\n"; // Emit the constructor of the class... OS << ClassName << "::" << ClassName From nicholas at mxc.ca Sat Nov 14 00:15:15 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 14 Nov 2009 06:15:15 -0000 Subject: [llvm-commits] [llvm] r88760 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Transforms/DeadStoreElimination/const-pointers.ll Message-ID: <200911140615.nAE6FFC6007099@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 14 00:15:14 2009 New Revision: 88760 URL: http://llvm.org/viewvc/llvm-project?rev=88760&view=rev Log: Teach BasicAA that a constant expression can't alias memory provably not allocated until runtime (such as an alloca). Patch by Hans Wennborg! Added: llvm/trunk/test/Transforms/DeadStoreElimination/const-pointers.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=88760&r1=88759&r2=88760&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sat Nov 14 00:15:14 2009 @@ -659,7 +659,12 @@ // If V1/V2 point to two different objects we know that we have no alias. if (isIdentifiedObject(O1) && isIdentifiedObject(O2)) return NoAlias; - + + // Constant pointers can't alias with non-const isIdentifiedObject objects. + if ((isa(O1) && isIdentifiedObject(O2) && !isa(O2)) || + (isa(O2) && isIdentifiedObject(O1) && !isa(O1))) + return NoAlias; + // Arguments can't alias with local allocations or noalias calls. if ((isa(O1) && (isa(O2) || isNoAliasCall(O2))) || (isa(O2) && (isa(O1) || isNoAliasCall(O1)))) Added: llvm/trunk/test/Transforms/DeadStoreElimination/const-pointers.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/const-pointers.ll?rev=88760&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/const-pointers.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/const-pointers.ll Sat Nov 14 00:15:14 2009 @@ -0,0 +1,39 @@ +; RUN: opt %s -dse -S | FileCheck %s + +%t = type { i32 } + + at g = global i32 42; + +define void @test1(%t* noalias %pp) { + %p = getelementptr inbounds %t* %pp, i32 0, i32 0 + + store i32 1, i32* %p; <-- This is dead + %x = load i32* inttoptr (i32 12345 to i32*) + store i32 %x, i32* %p + ret void +; CHECK define void @test1 +; CHECK: store +; CHECK-NOT: store +; CHECK: ret void +} + +define void @test3() { + store i32 1, i32* @g; <-- This is dead. + store i32 42, i32* @g + ret void +;CHECK define void @test3 +;CHECK: store +;CHECK-NOT: store +;CHECK: ret void +} + +define void @test4(i32* %p) { + store i32 1, i32* %p + %x = load i32* @g; <-- %p and @g could alias + store i32 %x, i32* %p + ret void +; CHECK define void @test4 +; CHECK: store +; CHECK: store +; CHECK: ret void +} From chandlerc at google.com Sat Nov 14 00:18:31 2009 From: chandlerc at google.com (Chandler Carruth) Date: Fri, 13 Nov 2009 22:18:31 -0800 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <20091113114804.GA34165@freebsd.org> References: <20091113114804.GA34165@freebsd.org> Message-ID: <74c447500911132218v7cd1b0edv6e6c32631848452c@mail.gmail.com> On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: > hi > > the attached patch moves cpu detection code from lib/Target/$FOO > (for FOO=X86 :) ) to lib/System. This is necessary for clang > to be able to do -march=native. The patch was already reviewed > by Daniel Dunbar. > > Can you please review/commit this? A meta-point: you're moving a lot more than just GetCurrentX86CPU into libSystem, can you expose the other functions and delete the copies in X86Subtarget? I'd rather avoid duplicating subtle code like that. Also, why add the include on StringMap? > > thnx! > > roman > > p.s. CC: me as I am not subscribed to llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From sanjiv.gupta at microchip.com Sat Nov 14 00:19:49 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Sat, 14 Nov 2009 06:19:49 -0000 Subject: [llvm-commits] [llvm] r88761 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200911140619.nAE6JneM007219@zion.cs.uiuc.edu> Author: sgupta Date: Sat Nov 14 00:19:49 2009 New Revision: 88761 URL: http://llvm.org/viewvc/llvm-project?rev=88761&view=rev Log: Fix debug info crashes for PIC16. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=88761&r1=88760&r2=88761&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Nov 14 00:19:49 2009 @@ -138,7 +138,7 @@ if (MMI) MMI->AnalyzeModule(M); DW = getAnalysisIfAvailable(); - if (DW) + if (DW && MAI->doesSupportDebugInformation()) DW->BeginModule(&M, MMI, O, this, MAI); return false; Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=88761&r1=88760&r2=88761&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Sat Nov 14 00:19:49 2009 @@ -467,12 +467,18 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) { // Get the file path from CU. DICompileUnit cu(CU); - std::string DirName = cu.getDirectory(); - std::string FileName = cu.getFilename(); - std::string FilePath = DirName + "/" + FileName; + std::string FilePath = ""; + if (cu.getDirectory()) { + std::string DirName = cu.getDirectory(); + FilePath = FilePath + DirName + "/"; + } + if (cu.getFilename()) { + std::string FileName = cu.getFilename(); + FilePath = FilePath + FileName; + } - // Nothing to do if source file is still same. - if ( FilePath == CurFile ) return; + // Nothing to do if source file is still same or it is empty. + if ( FilePath == CurFile || FilePath == "") return; // Else, close the current one and start a new. if (CurFile != "") O << "\n\t.eof"; From sanjiv.gupta at microchip.com Sat Nov 14 01:22:25 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Sat, 14 Nov 2009 07:22:25 -0000 Subject: [llvm-commits] [llvm] r88762 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200911140722.nAE7MPwB008941@zion.cs.uiuc.edu> Author: sgupta Date: Sat Nov 14 01:22:25 2009 New Revision: 88762 URL: http://llvm.org/viewvc/llvm-project?rev=88762&view=rev Log: revert 88761 as it fails builds. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=88762&r1=88761&r2=88762&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Nov 14 01:22:25 2009 @@ -138,7 +138,7 @@ if (MMI) MMI->AnalyzeModule(M); DW = getAnalysisIfAvailable(); - if (DW && MAI->doesSupportDebugInformation()) + if (DW) DW->BeginModule(&M, MMI, O, this, MAI); return false; Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=88762&r1=88761&r2=88762&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Sat Nov 14 01:22:25 2009 @@ -467,18 +467,12 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) { // Get the file path from CU. DICompileUnit cu(CU); - std::string FilePath = ""; - if (cu.getDirectory()) { - std::string DirName = cu.getDirectory(); - FilePath = FilePath + DirName + "/"; - } - if (cu.getFilename()) { - std::string FileName = cu.getFilename(); - FilePath = FilePath + FileName; - } + std::string DirName = cu.getDirectory(); + std::string FileName = cu.getFilename(); + std::string FilePath = DirName + "/" + FileName; - // Nothing to do if source file is still same or it is empty. - if ( FilePath == CurFile || FilePath == "") return; + // Nothing to do if source file is still same. + if ( FilePath == CurFile ) return; // Else, close the current one and start a new. if (CurFile != "") O << "\n\t.eof"; From nicholas at mxc.ca Sat Nov 14 01:25:55 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 14 Nov 2009 07:25:55 -0000 Subject: [llvm-commits] [llvm] r88763 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Message-ID: <200911140725.nAE7PtS0009032@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 14 01:25:54 2009 New Revision: 88763 URL: http://llvm.org/viewvc/llvm-project?rev=88763&view=rev Log: Remove LLVMContext from reassociate. It was threaded through every function but ultimately never used. Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=88763&r1=88762&r2=88763&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Sat Nov 14 01:25:54 2009 @@ -27,7 +27,6 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" -#include "llvm/LLVMContext.h" #include "llvm/Pass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" @@ -198,8 +197,7 @@ /// LowerNegateToMultiply - Replace 0-X with X*-1. /// static Instruction *LowerNegateToMultiply(Instruction *Neg, - std::map, unsigned> &ValueRankMap, - LLVMContext &Context) { + std::map, unsigned> &ValueRankMap) { Constant *Cst = Constant::getAllOnesValue(Neg->getType()); Instruction *Res = BinaryOperator::CreateMul(Neg->getOperand(1), Cst, "",Neg); @@ -255,7 +253,6 @@ std::vector &Ops) { Value *LHS = I->getOperand(0), *RHS = I->getOperand(1); unsigned Opcode = I->getOpcode(); - LLVMContext &Context = I->getContext(); // First step, linearize the expression if it is in ((A+B)+(C+D)) form. BinaryOperator *LHSBO = isReassociableOp(LHS, Opcode); @@ -265,13 +262,11 @@ // transform them into multiplies by -1 so they can be reassociated. if (I->getOpcode() == Instruction::Mul) { if (!LHSBO && LHS->hasOneUse() && BinaryOperator::isNeg(LHS)) { - LHS = LowerNegateToMultiply(cast(LHS), - ValueRankMap, Context); + LHS = LowerNegateToMultiply(cast(LHS), ValueRankMap); LHSBO = isReassociableOp(LHS, Opcode); } if (!RHSBO && RHS->hasOneUse() && BinaryOperator::isNeg(RHS)) { - RHS = LowerNegateToMultiply(cast(RHS), - ValueRankMap, Context); + RHS = LowerNegateToMultiply(cast(RHS), ValueRankMap); RHSBO = isReassociableOp(RHS, Opcode); } } @@ -373,7 +368,7 @@ // version of the value is returned, and BI is left pointing at the instruction // that should be processed next by the reassociation pass. // -static Value *NegateValue(LLVMContext &Context, Value *V, Instruction *BI) { +static Value *NegateValue(Value *V, Instruction *BI) { // We are trying to expose opportunity for reassociation. One of the things // that we want to do to achieve this is to push a negation as deep into an // expression chain as possible, to expose the add instructions. In practice, @@ -386,8 +381,8 @@ if (Instruction *I = dyn_cast(V)) if (I->getOpcode() == Instruction::Add && I->hasOneUse()) { // Push the negates through the add. - I->setOperand(0, NegateValue(Context, I->getOperand(0), BI)); - I->setOperand(1, NegateValue(Context, I->getOperand(1), BI)); + I->setOperand(0, NegateValue(I->getOperand(0), BI)); + I->setOperand(1, NegateValue(I->getOperand(1), BI)); // We must move the add instruction here, because the neg instructions do // not dominate the old add instruction in general. By moving it, we are @@ -407,7 +402,7 @@ /// ShouldBreakUpSubtract - Return true if we should break up this subtract of /// X-Y into (X + -Y). -static bool ShouldBreakUpSubtract(LLVMContext &Context, Instruction *Sub) { +static bool ShouldBreakUpSubtract(Instruction *Sub) { // If this is a negation, we can't split it up! if (BinaryOperator::isNeg(Sub)) return false; @@ -431,7 +426,7 @@ /// BreakUpSubtract - If we have (X-Y), and if either X is an add, or if this is /// only used by an add, transform this into (X+(0-Y)) to promote better /// reassociation. -static Instruction *BreakUpSubtract(LLVMContext &Context, Instruction *Sub, +static Instruction *BreakUpSubtract(Instruction *Sub, std::map, unsigned> &ValueRankMap) { // Convert a subtract into an add and a neg instruction... so that sub // instructions can be commuted with other add instructions... @@ -439,7 +434,7 @@ // Calculate the negative value of Operand 1 of the sub instruction... // and set it as the RHS of the add instruction we just made... // - Value *NegVal = NegateValue(Context, Sub->getOperand(1), Sub); + Value *NegVal = NegateValue(Sub->getOperand(1), Sub); Instruction *New = BinaryOperator::CreateAdd(Sub->getOperand(0), NegVal, "", Sub); New->takeName(Sub); @@ -457,8 +452,7 @@ /// by one, change this into a multiply by a constant to assist with further /// reassociation. static Instruction *ConvertShiftToMul(Instruction *Shl, - std::map, unsigned> &ValueRankMap, - LLVMContext &Context) { + std::map, unsigned> &ValueRankMap) { // If an operand of this shift is a reassociable multiply, or if the shift // is used by a reassociable multiply or add, turn into a multiply. if (isReassociableOp(Shl->getOperand(0), Instruction::Mul) || @@ -781,13 +775,11 @@ /// ReassociateBB - Inspect all of the instructions in this basic block, /// reassociating them as we go. void Reassociate::ReassociateBB(BasicBlock *BB) { - LLVMContext &Context = BB->getContext(); - for (BasicBlock::iterator BBI = BB->begin(); BBI != BB->end(); ) { Instruction *BI = BBI++; if (BI->getOpcode() == Instruction::Shl && isa(BI->getOperand(1))) - if (Instruction *NI = ConvertShiftToMul(BI, ValueRankMap, Context)) { + if (Instruction *NI = ConvertShiftToMul(BI, ValueRankMap)) { MadeChange = true; BI = NI; } @@ -800,8 +792,8 @@ // If this is a subtract instruction which is not already in negate form, // see if we can convert it to X+-Y. if (BI->getOpcode() == Instruction::Sub) { - if (ShouldBreakUpSubtract(Context, BI)) { - BI = BreakUpSubtract(Context, BI, ValueRankMap); + if (ShouldBreakUpSubtract(BI)) { + BI = BreakUpSubtract(BI, ValueRankMap); MadeChange = true; } else if (BinaryOperator::isNeg(BI)) { // Otherwise, this is a negation. See if the operand is a multiply tree @@ -809,7 +801,7 @@ if (isReassociableOp(BI->getOperand(1), Instruction::Mul) && (!BI->hasOneUse() || !isReassociableOp(BI->use_back(), Instruction::Mul))) { - BI = LowerNegateToMultiply(BI, ValueRankMap, Context); + BI = LowerNegateToMultiply(BI, ValueRankMap); MadeChange = true; } } From rdivacky at freebsd.org Sat Nov 14 03:13:08 2009 From: rdivacky at freebsd.org (Roman Divacky) Date: Sat, 14 Nov 2009 10:13:08 +0100 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <74c447500911132218v7cd1b0edv6e6c32631848452c@mail.gmail.com> References: <20091113114804.GA34165@freebsd.org> <74c447500911132218v7cd1b0edv6e6c32631848452c@mail.gmail.com> Message-ID: <20091114091307.GA61553@freebsd.org> On Fri, Nov 13, 2009 at 10:18:31PM -0800, Chandler Carruth wrote: > On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: > > hi > > > > the attached patch moves cpu detection code from lib/Target/$FOO > > (for FOO=X86 :) ) to lib/System. This is necessary for clang > > to be able to do -march=native. The patch was already reviewed > > by Daniel Dunbar. > > > > Can you please review/commit this? > > A meta-point: you're moving a lot more than just GetCurrentX86CPU into > libSystem, can you expose the other functions and delete the copies in > X86Subtarget? I'd rather avoid duplicating subtle code like that. I was told to not expose any target specific functionality, the GetX86CpuIDAndInfo and DetectX86FamilyModel are fairly small and not likely to change often. I dont like the duplication either butcant think of any way to reach this X86 specific stuff from libSystem. > Also, why add the include on StringMap? oh.. leftover from previous attempts :) new patch attached thnx for review! -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-march=native.patch Type: text/x-diff Size: 10585 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091114/11117492/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091114/11117492/attachment-0001.bin From chandlerc at google.com Sat Nov 14 03:46:21 2009 From: chandlerc at google.com (Chandler Carruth) Date: Sat, 14 Nov 2009 01:46:21 -0800 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <20091114091307.GA61553@freebsd.org> References: <20091113114804.GA34165@freebsd.org> <74c447500911132218v7cd1b0edv6e6c32631848452c@mail.gmail.com> <20091114091307.GA61553@freebsd.org> Message-ID: <74c447500911140146k75be1104w6c7759ffd6b7e91e@mail.gmail.com> On Sat, Nov 14, 2009 at 1:13 AM, Roman Divacky wrote: > On Fri, Nov 13, 2009 at 10:18:31PM -0800, Chandler Carruth wrote: >> On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: >> > hi >> > >> > the attached patch moves cpu detection code from lib/Target/$FOO >> > (for FOO=X86 :) ) to lib/System. This is necessary for clang >> > to be able to do -march=native. The patch was already reviewed >> > by Daniel Dunbar. >> > >> > Can you please review/commit this? >> >> A meta-point: you're moving a lot more than just GetCurrentX86CPU into >> libSystem, can you expose the other functions and delete the copies in >> X86Subtarget? I'd rather avoid duplicating subtle code like that. > > I was told to not expose any target specific functionality, the > GetX86CpuIDAndInfo and DetectX86FamilyModel are fairly small and not > likely to change often. I dont like the duplication either butcant think of > any way to reach this X86 specific stuff from libSystem. I was thinking the other way around: expose this in libSystem so that the X86 target can leverage it. I agree libSystem shouldn't depend on libTarget. That said, I don't have a clean API for it at first glance -- I suspect each target has its own target-specific routines it needs access to -- but if these are useful for the host as well as the target, it makes sense to me for them to live in libSystem rather than a target library. Maybe others have ideas on how best to organize such helper routines? > >> Also, why add the include on StringMap? > > oh.. leftover from previous attempts :) > > new patch attached > > thnx for review! > From rdivacky at freebsd.org Sat Nov 14 03:48:14 2009 From: rdivacky at freebsd.org (Roman Divacky) Date: Sat, 14 Nov 2009 10:48:14 +0100 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <74c447500911140146k75be1104w6c7759ffd6b7e91e@mail.gmail.com> References: <20091113114804.GA34165@freebsd.org> <74c447500911132218v7cd1b0edv6e6c32631848452c@mail.gmail.com> <20091114091307.GA61553@freebsd.org> <74c447500911140146k75be1104w6c7759ffd6b7e91e@mail.gmail.com> Message-ID: <20091114094814.GA66500@freebsd.org> On Sat, Nov 14, 2009 at 01:46:21AM -0800, Chandler Carruth wrote: > On Sat, Nov 14, 2009 at 1:13 AM, Roman Divacky wrote: > > On Fri, Nov 13, 2009 at 10:18:31PM -0800, Chandler Carruth wrote: > >> On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: > >> > hi > >> > > >> > the attached patch moves cpu detection code from lib/Target/$FOO > >> > (for FOO=X86 :) ) to lib/System. This is necessary for clang > >> > to be able to do -march=native. The patch was already reviewed > >> > by Daniel Dunbar. > >> > > >> > Can you please review/commit this? > >> > >> A meta-point: you're moving a lot more than just GetCurrentX86CPU into > >> libSystem, can you expose the other functions and delete the copies in > >> X86Subtarget? I'd rather avoid duplicating subtle code like that. > > > > I was told to not expose any target specific functionality, the > > GetX86CpuIDAndInfo and DetectX86FamilyModel are fairly small and not > > likely to change often. I dont like the duplication either butcant think of > > any way to reach this X86 specific stuff from libSystem. > > I was thinking the other way around: expose this in libSystem so that > the X86 target can leverage it. I agree libSystem shouldn't depend on > libTarget. I know... I already did it like this but daniel preferred this way. I have to agree that this looks better > That said, I don't have a clean API for it at first glance -- I > suspect each target has its own target-specific routines it needs > access to -- but if these are useful for the host as well as the > target, it makes sense to me for them to live in libSystem rather than > a target library. Maybe others have ideas on how best to organize such > helper routines? I have no idea.... From daniel at zuster.org Sat Nov 14 04:04:43 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 02:04:43 -0800 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <20091113114804.GA34165@freebsd.org> References: <20091113114804.GA34165@freebsd.org> Message-ID: <6a8523d60911140204l5d0cc55l90c323099e487a1a@mail.gmail.com> Applied as r, with the extra StringMap include dropped. Thank you very much, this has long been on my TODO list. Are you also working on the target features part of this work? On Sat, Nov 14, 2009 at 1:48 AM, Roman Divacky wrote: > On Sat, Nov 14, 2009 at 01:46:21AM -0800, Chandler Carruth wrote: >> On Sat, Nov 14, 2009 at 1:13 AM, Roman Divacky wrote: >> > On Fri, Nov 13, 2009 at 10:18:31PM -0800, Chandler Carruth wrote: >> >> On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: >> >> A meta-point: you're moving a lot more than just GetCurrentX86CPU into >> >> libSystem, can you expose the other functions and delete the copies in >> >> X86Subtarget? I'd rather avoid duplicating subtle code like that. >> > >> > I was told to not expose any target specific functionality, the >> > GetX86CpuIDAndInfo and DetectX86FamilyModel are fairly small and not >> > likely to change often. I dont like the duplication either butcant think of >> > any way to reach this X86 specific stuff from libSystem. >> >> I was thinking the other way around: expose this in libSystem so that >> the X86 target can leverage it. I agree libSystem shouldn't depend on >> libTarget. > > I know... I already did it like this but daniel preferred this way. I have > to agree that this looks better http://llvm.org/bugs/show_bug.cgi?id=5389 has the relevant context for those late to the party. Basically I want to eliminate any host specific code in the targets themselves -- the frontend and tools should have complete control over this. The idea is to add another routine to detect the set of "features", and then move tools like the JIT and llc to use this if they want to match the host, instead of relying on the backend to do it. - Daniel On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: > hi > > the attached patch moves cpu detection code from lib/Target/$FOO > (for FOO=X86 :) ) to lib/System. This is necessary for clang > to be able to do -march=native. The patch was already reviewed > by Daniel Dunbar. > > Can you please review/commit this? > > thnx! > > roman > > p.s. CC: me as I am not subscribed to llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From daniel at zuster.org Sat Nov 14 04:09:13 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 10:09:13 -0000 Subject: [llvm-commits] [llvm] r88768 - in /llvm/trunk: include/llvm/System/Host.h lib/System/Host.cpp lib/Target/X86/X86Subtarget.cpp Message-ID: <200911141009.nAEA9DUn027955@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 14 04:09:12 2009 New Revision: 88768 URL: http://llvm.org/viewvc/llvm-project?rev=88768&view=rev Log: Add llvm::sys::getHostCPUName, for detecting the LLVM name for the host CPU. - This is an initial step towards -march=native support in Clang, and towards eliminating host dependencies in the targets. See PR5389. - Patch by Roman Divacky! Modified: llvm/trunk/include/llvm/System/Host.h llvm/trunk/lib/System/Host.cpp llvm/trunk/lib/Target/X86/X86Subtarget.cpp Modified: llvm/trunk/include/llvm/System/Host.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Host.h?rev=88768&r1=88767&r2=88768&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Host.h (original) +++ llvm/trunk/include/llvm/System/Host.h Sat Nov 14 04:09:12 2009 @@ -41,6 +41,12 @@ /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM std::string getHostTriple(); + /// getHostCPUName - Get the LLVM name for the host CPU. The particular format + /// of the name is target dependent, and suitable for passing as -mcpu to the + /// target which matches the host. + /// + /// \return - The host CPU name, or empty if the CPU could not be determined. + std::string getHostCPUName(); } } Modified: llvm/trunk/lib/System/Host.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Host.cpp?rev=88768&r1=88767&r2=88768&view=diff ============================================================================== --- llvm/trunk/lib/System/Host.cpp (original) +++ llvm/trunk/lib/System/Host.cpp Sat Nov 14 04:09:12 2009 @@ -13,6 +13,7 @@ #include "llvm/System/Host.h" #include "llvm/Config/config.h" +#include // Include the platform-specific parts of this class. #ifdef LLVM_ON_UNIX @@ -22,3 +23,198 @@ #include "Win32/Host.inc" #endif +//===----------------------------------------------------------------------===// +// +// Implementations of the CPU detection routines +// +//===----------------------------------------------------------------------===// + +using namespace llvm; + +#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\ + || defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64) + +/// GetX86CpuIDAndInfo - Execute the specified cpuid and return the 4 values in the +/// specified arguments. If we can't run cpuid on the host, return true. +static bool GetX86CpuIDAndInfo(unsigned value, unsigned *rEAX, + unsigned *rEBX, unsigned *rECX, unsigned *rEDX) { +#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64) + #if defined(__GNUC__) + // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually. + asm ("movq\t%%rbx, %%rsi\n\t" + "cpuid\n\t" + "xchgq\t%%rbx, %%rsi\n\t" + : "=a" (*rEAX), + "=S" (*rEBX), + "=c" (*rECX), + "=d" (*rEDX) + : "a" (value)); + return false; + #elif defined(_MSC_VER) + int registers[4]; + __cpuid(registers, value); + *rEAX = registers[0]; + *rEBX = registers[1]; + *rECX = registers[2]; + *rEDX = registers[3]; + return false; + #endif +#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86) + #if defined(__GNUC__) + asm ("movl\t%%ebx, %%esi\n\t" + "cpuid\n\t" + "xchgl\t%%ebx, %%esi\n\t" + : "=a" (*rEAX), + "=S" (*rEBX), + "=c" (*rECX), + "=d" (*rEDX) + : "a" (value)); + return false; + #elif defined(_MSC_VER) + __asm { + mov eax,value + cpuid + mov esi,rEAX + mov dword ptr [esi],eax + mov esi,rEBX + mov dword ptr [esi],ebx + mov esi,rECX + mov dword ptr [esi],ecx + mov esi,rEDX + mov dword ptr [esi],edx + } + return false; + #endif +#endif + return true; +} + +static void DetectX86FamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) { + Family = (EAX >> 8) & 0xf; // Bits 8 - 11 + Model = (EAX >> 4) & 0xf; // Bits 4 - 7 + if (Family == 6 || Family == 0xf) { + if (Family == 0xf) + // Examine extended family ID if family ID is F. + Family += (EAX >> 20) & 0xff; // Bits 20 - 27 + // Examine extended model ID if family ID is 6 or F. + Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19 + } +} +#endif + + +std::string sys::getHostCPUName() { +#if defined(__x86_64__) || defined(__i386__) + unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; + if (GetX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX)) + return "generic"; + unsigned Family = 0; + unsigned Model = 0; + DetectX86FamilyModel(EAX, Family, Model); + + GetX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX); + bool Em64T = (EDX >> 29) & 0x1; + bool HasSSE3 = (ECX & 0x1); + + union { + unsigned u[3]; + char c[12]; + } text; + + GetX86CpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1); + if (memcmp(text.c, "GenuineIntel", 12) == 0) { + switch (Family) { + case 3: + return "i386"; + case 4: + return "i486"; + case 5: + switch (Model) { + case 4: return "pentium-mmx"; + default: return "pentium"; + } + case 6: + switch (Model) { + case 1: return "pentiumpro"; + case 3: + case 5: + case 6: return "pentium2"; + case 7: + case 8: + case 10: + case 11: return "pentium3"; + case 9: + case 13: return "pentium-m"; + case 14: return "yonah"; + case 15: + case 22: // Celeron M 540 + return "core2"; + case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE) + return "penryn"; + default: return "i686"; + } + case 15: { + switch (Model) { + case 3: + case 4: + case 6: // same as 4, but 65nm + return (Em64T) ? "nocona" : "prescott"; + case 26: + return "corei7"; + case 28: + return "atom"; + default: + return (Em64T) ? "x86-64" : "pentium4"; + } + } + + default: + return "generic"; + } + } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) { + // FIXME: this poorly matches the generated SubtargetFeatureKV table. There + // appears to be no way to generate the wide variety of AMD-specific targets + // from the information returned from CPUID. + switch (Family) { + case 4: + return "i486"; + case 5: + switch (Model) { + case 6: + case 7: return "k6"; + case 8: return "k6-2"; + case 9: + case 13: return "k6-3"; + default: return "pentium"; + } + case 6: + switch (Model) { + case 4: return "athlon-tbird"; + case 6: + case 7: + case 8: return "athlon-mp"; + case 10: return "athlon-xp"; + default: return "athlon"; + } + case 15: + if (HasSSE3) { + return "k8-sse3"; + } else { + switch (Model) { + case 1: return "opteron"; + case 5: return "athlon-fx"; // also opteron + default: return "athlon64"; + } + } + case 16: + return "amdfam10"; + default: + return "generic"; + } + } else { + return "generic"; + } +#else + return "generic"; +#endif +} Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=88768&r1=88767&r2=88768&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Sat Nov 14 04:09:12 2009 @@ -18,6 +18,7 @@ #include "llvm/GlobalValue.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/System/Host.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/ADT/SmallVector.h" @@ -258,118 +259,6 @@ } } -static const char *GetCurrentX86CPU() { - unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; - if (GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX)) - return "generic"; - unsigned Family = 0; - unsigned Model = 0; - DetectFamilyModel(EAX, Family, Model); - - GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX); - bool Em64T = (EDX >> 29) & 0x1; - bool HasSSE3 = (ECX & 0x1); - - union { - unsigned u[3]; - char c[12]; - } text; - - GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1); - if (memcmp(text.c, "GenuineIntel", 12) == 0) { - switch (Family) { - case 3: - return "i386"; - case 4: - return "i486"; - case 5: - switch (Model) { - case 4: return "pentium-mmx"; - default: return "pentium"; - } - case 6: - switch (Model) { - case 1: return "pentiumpro"; - case 3: - case 5: - case 6: return "pentium2"; - case 7: - case 8: - case 10: - case 11: return "pentium3"; - case 9: - case 13: return "pentium-m"; - case 14: return "yonah"; - case 15: - case 22: // Celeron M 540 - return "core2"; - case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE) - return "penryn"; - default: return "i686"; - } - case 15: { - switch (Model) { - case 3: - case 4: - case 6: // same as 4, but 65nm - return (Em64T) ? "nocona" : "prescott"; - case 26: - return "corei7"; - case 28: - return "atom"; - default: - return (Em64T) ? "x86-64" : "pentium4"; - } - } - - default: - return "generic"; - } - } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) { - // FIXME: this poorly matches the generated SubtargetFeatureKV table. There - // appears to be no way to generate the wide variety of AMD-specific targets - // from the information returned from CPUID. - switch (Family) { - case 4: - return "i486"; - case 5: - switch (Model) { - case 6: - case 7: return "k6"; - case 8: return "k6-2"; - case 9: - case 13: return "k6-3"; - default: return "pentium"; - } - case 6: - switch (Model) { - case 4: return "athlon-tbird"; - case 6: - case 7: - case 8: return "athlon-mp"; - case 10: return "athlon-xp"; - default: return "athlon"; - } - case 15: - if (HasSSE3) { - return "k8-sse3"; - } else { - switch (Model) { - case 1: return "opteron"; - case 5: return "athlon-fx"; // also opteron - default: return "athlon64"; - } - } - case 16: - return "amdfam10"; - default: - return "generic"; - } - } else { - return "generic"; - } -} - X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS, bool is64Bit) : PICStyle(PICStyles::None) @@ -396,7 +285,7 @@ // Determine default and user specified characteristics if (!FS.empty()) { // If feature string is not empty, parse features string. - std::string CPU = GetCurrentX86CPU(); + std::string CPU = sys::getHostCPUName(); ParseSubtargetFeatures(FS, CPU); // All X86-64 CPUs also have SSE2, however user might request no SSE via // -mattr, so don't force SSELevel here. From daniel at zuster.org Sat Nov 14 04:09:35 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 02:09:35 -0800 Subject: [llvm-commits] move CPU detection from lib/Target/$FOO to libSystem In-Reply-To: <6a8523d60911140204l5d0cc55l90c323099e487a1a@mail.gmail.com> References: <20091113114804.GA34165@freebsd.org> <6a8523d60911140204l5d0cc55l90c323099e487a1a@mail.gmail.com> Message-ID: <6a8523d60911140209l55897f6cs2e0d822d90e64206@mail.gmail.com> On Sat, Nov 14, 2009 at 2:04 AM, Daniel Dunbar wrote: > Applied as r, with the extra StringMap include dropped. Thank you very Err, r88768. - Daniel > much, this has long been on my TODO list. > > Are you also working on the target features part of this work? > > On Sat, Nov 14, 2009 at 1:48 AM, Roman Divacky wrote: >> On Sat, Nov 14, 2009 at 01:46:21AM -0800, Chandler Carruth wrote: >>> On Sat, Nov 14, 2009 at 1:13 AM, Roman Divacky wrote: >>> > On Fri, Nov 13, 2009 at 10:18:31PM -0800, Chandler Carruth wrote: >>> >> On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: > >>> >> A meta-point: you're moving a lot more than just GetCurrentX86CPU into >>> >> libSystem, can you expose the other functions and delete the copies in >>> >> X86Subtarget? I'd rather avoid duplicating subtle code like that. >>> > >>> > I was told to not expose any target specific functionality, the >>> > GetX86CpuIDAndInfo and DetectX86FamilyModel are fairly small and not >>> > likely to change often. I dont like the duplication either butcant think of >>> > any way to reach this X86 specific stuff from libSystem. >>> >>> I was thinking the other way around: expose this in libSystem so that >>> the X86 target can leverage it. I agree libSystem shouldn't depend on >>> libTarget. >> >> I know... I already did it like this but daniel preferred this way. I have >> to agree that this looks better > > ?http://llvm.org/bugs/show_bug.cgi?id=5389 > has the relevant context for those late to the party. > > Basically I want to eliminate any host specific code in the targets > themselves -- the frontend and tools should have complete control over > this. The idea is to add another routine to detect the set of > "features", and then move tools like the JIT and llc to use this if > they want to match the host, instead of relying on the backend to do > it. > > ?- Daniel > > On Fri, Nov 13, 2009 at 3:48 AM, Roman Divacky wrote: >> hi >> >> the attached patch moves cpu detection code from lib/Target/$FOO >> (for FOO=X86 :) ) to lib/System. This is necessary for clang >> to be able to do -march=native. The patch was already reviewed >> by Daniel Dunbar. >> >> Can you please review/commit this? >> >> thnx! >> >> roman >> >> p.s. CC: me as I am not subscribed to llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> > From baldrick at free.fr Sat Nov 14 04:20:46 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 10:20:46 -0000 Subject: [llvm-commits] [dragonegg] r88769 - in /dragonegg/trunk: llvm-abi.h llvm-types.cpp x86/llvm-target.h Message-ID: <200911141020.nAEAKkgY028441@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 04:20:46 2009 New Revision: 88769 URL: http://llvm.org/viewvc/llvm-project?rev=88769&view=rev Log: Port commit 85539 (bwilson) from llvm-gcc: Fix ARM AAPCS-VFP return of homogeneous aggregates. Patch by Sandeep Patel. Modified: dragonegg/trunk/llvm-abi.h dragonegg/trunk/llvm-types.cpp dragonegg/trunk/x86/llvm-target.h Modified: dragonegg/trunk/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88769&r1=88768&r2=88769&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi.h (original) +++ dragonegg/trunk/llvm-abi.h Sat Nov 14 04:20:46 2009 @@ -124,15 +124,24 @@ false #endif +// LLVM_SHOULD_NOT_USE_SHADOW_RETURN - A hook to allow aggregates to be +// returned in registers. +#ifndef LLVM_SHOULD_NOT_USE_SHADOW_RETURN +#define LLVM_SHOULD_NOT_USE_SHADOW_RETURN(X, CC) \ + false +#endif + // doNotUseShadowReturn - Return true if the specified GCC type // should not be returned using a pointer to struct parameter. -static inline bool doNotUseShadowReturn(tree type, tree fndecl) { +static inline bool doNotUseShadowReturn(tree type, tree fndecl, + CallingConv::ID CC) { if (!TYPE_SIZE(type)) return false; if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST) return false; // LLVM says do not use shadow argument. - if (LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(type)) + if (LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(type) || + LLVM_SHOULD_NOT_USE_SHADOW_RETURN(type, CC)) return true; // GCC says use shadow argument. if (aggregate_value_p(type, fndecl)) @@ -394,7 +403,7 @@ } else if (Ty->isSingleValueType() || Ty->isVoidTy()) { // Return scalar values normally. C.HandleScalarResult(Ty); - } else if (doNotUseShadowReturn(type, fn)) { + } else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) { tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type); if (SingleElt && TYPE_SIZE(SingleElt) && TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST && @@ -404,7 +413,8 @@ } else { // Otherwise return as an integer value large enough to hold the entire // aggregate. - if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type)) + if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type, + C.getCallingConv())) C.HandleAggregateResultAsAggregate(AggrTy); else if (const Type* ScalarTy = LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(type, &Offset)) @@ -753,7 +763,7 @@ } else if (Ty->isSingleValueType() || Ty->isVoidTy()) { // Return scalar values normally. C.HandleScalarResult(Ty); - } else if (doNotUseShadowReturn(type, fn)) { + } else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) { tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type); if (SingleElt && TYPE_SIZE(SingleElt) && TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST && @@ -763,7 +773,8 @@ } else { // Otherwise return as an integer value large enough to hold the entire // aggregate. - if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type)) + if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type, + C.getCallingConv())) C.HandleAggregateResultAsAggregate(AggrTy); else if (const Type* ScalarTy = LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(type, &Offset)) Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=88769&r1=88768&r2=88769&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Sat Nov 14 04:20:46 2009 @@ -1024,16 +1024,16 @@ tree ReturnType = TREE_TYPE(type); std::vector ArgTys; PATypeHolder RetTy(Type::getVoidTy(Context)); - + FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/); TheLLVMABI ABIConverter(Client); - - // Builtins are always prototyped, so this isn't one. - ABIConverter.HandleReturnType(ReturnType, current_function_decl, false); #ifdef TARGET_ADJUST_LLVM_CC - TARGET_ADJUST_LLVM_CC(CallingConv, type); + TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif + + // Builtins are always prototyped, so this isn't one. + ABIConverter.HandleReturnType(ReturnType, current_function_decl, false); SmallVector Attrs; @@ -1090,15 +1090,15 @@ bool isVarArg = false; FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/); TheLLVMABI ABIConverter(Client); - - ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl, - decl ? DECL_BUILT_IN(decl) : false); - + // Allow the target to set the CC for things like fastcall etc. #ifdef TARGET_ADJUST_LLVM_CC TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif + ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl, + decl ? DECL_BUILT_IN(decl) : false); + // Compute attributes for return type (and function attributes). SmallVector Attrs; Attributes FnAttributes = Attribute::None; Modified: dragonegg/trunk/x86/llvm-target.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.h?rev=88769&r1=88768&r2=88769&view=diff ============================================================================== --- dragonegg/trunk/x86/llvm-target.h (original) +++ dragonegg/trunk/x86/llvm-target.h Sat Nov 14 04:20:46 2009 @@ -137,7 +137,7 @@ /* LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be returned as an aggregate, otherwise return NULL. */ -#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X) \ +#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X, CC) \ llvm_x86_aggr_type_for_struct_return(X) extern void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest, From baldrick at free.fr Sat Nov 14 04:35:22 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 10:35:22 -0000 Subject: [llvm-commits] [dragonegg] r88770 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911141035.nAEAZMAl028872@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 04:35:22 2009 New Revision: 88770 URL: http://llvm.org/viewvc/llvm-project?rev=88770&view=rev Log: Port commit 85580 (evancheng) from llvm-gcc: This makes no sense. Optimize < 3 should not mean optimize_size. They are two different concepts. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=88770&r1=88769&r2=88770&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Sat Nov 14 04:35:22 2009 @@ -698,7 +698,7 @@ HasPerModulePasses = true; createStandardModulePasses(PerModulePasses, optimize, - optimize_size || optimize < 3, + optimize_size, flag_unit_at_a_time, flag_unroll_loops, !flag_no_simplify_libcalls, flag_exceptions, InliningPass); From baldrick at free.fr Sat Nov 14 04:41:46 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 10:41:46 -0000 Subject: [llvm-commits] [dragonegg] r88771 - /dragonegg/trunk/llvm-abi.h Message-ID: <200911141041.nAEAfkbF029053@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 04:41:46 2009 New Revision: 88771 URL: http://llvm.org/viewvc/llvm-project?rev=88771&view=rev Log: Port commit 85593 (bwilson) from llvm-gcc: Fix llvm-gcc build for non-x86/ARM targets. Modified: dragonegg/trunk/llvm-abi.h Modified: dragonegg/trunk/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88771&r1=88770&r2=88771&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi.h (original) +++ dragonegg/trunk/llvm-abi.h Sat Nov 14 04:41:46 2009 @@ -351,7 +351,7 @@ // LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be // returned as an aggregate, otherwise return NULL. #ifndef LLVM_AGGR_TYPE_FOR_STRUCT_RETURN -#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X) \ +#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X, CC) \ getLLVMAggregateTypeForStructReturn(X) #endif From baldrick at free.fr Sat Nov 14 04:48:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 10:48:11 -0000 Subject: [llvm-commits] [dragonegg] r88775 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141048.nAEAmBrb029265@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 04:48:11 2009 New Revision: 88775 URL: http://llvm.org/viewvc/llvm-project?rev=88775&view=rev Log: Port commit 85631 (dpatel) from llvm-gcc: Do not use empty strings for name in debug info. It confuses other tools reading compiler generated output. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88775&r1=88774&r2=88775&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 04:48:11 2009 @@ -154,7 +154,7 @@ } } - return ""; + return NULL; } /// GetNodeLocation - Returns the location stored in a node regardless of @@ -211,7 +211,7 @@ return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(Node)); } } - return ""; + return NULL; } DebugInfo::DebugInfo(Module *m) @@ -447,7 +447,7 @@ DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size()); return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type, - findRegion(type), "", + findRegion(type), NULL, getOrCreateCompileUnit(NULL), 0, 0, 0, 0, 0, llvm::DIType(), EltTypeArray); @@ -521,7 +521,7 @@ DebugFactory.GetOrCreateArray(Subscripts.data(), Subscripts.size()); expanded_location Loc = GetNodeLocation(type); return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type, - findRegion(type), "", + findRegion(type), NULL, getOrCreateCompileUnit(Loc.file), 0, NodeSizeInBits(type), NodeAlignInBits(type), 0, 0, @@ -601,9 +601,14 @@ // reused because MDNodes are uniqued. To avoid this, use type context /// also while creating FwdDecl for now. std::string FwdName; - if (TYPE_CONTEXT(type)) - FwdName = GetNodeName(TYPE_CONTEXT(type)); - FwdName = FwdName + GetNodeName(type); + if (TYPE_CONTEXT(type)) { + const char *TypeContextName = GetNodeName(TYPE_CONTEXT(type)); + if (TypeContextName) + FwdName = TypeContextName; + } + const char *TypeName = GetNodeName(type); + if (TypeName) + FwdName = FwdName + TypeName; unsigned Flags = llvm::DIType::FlagFwdDecl; llvm::DICompositeType FwdDecl = DebugFactory.CreateCompositeType(Tag, @@ -634,7 +639,7 @@ // FIXME : name, size, align etc... DIType DTy = DebugFactory.CreateDerivedType(DW_TAG_inheritance, - findRegion(type), "", + findRegion(type), NULL, llvm::DICompileUnit(), 0,0,0, getINTEGER_CSTVal(BINFO_OFFSET(BInfo)), 0, BaseClass); @@ -753,7 +758,7 @@ if (TYPE_VOLATILE(type)) { Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type, - findRegion(type), "", + findRegion(type), NULL, getOrCreateCompileUnit(NULL), 0 /*line no*/, NodeSizeInBits(type), @@ -766,7 +771,7 @@ if (TYPE_READONLY(type)) Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type, - findRegion(type), "", + findRegion(type), NULL, getOrCreateCompileUnit(NULL), 0 /*line no*/, NodeSizeInBits(type), @@ -926,7 +931,7 @@ DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName, Directory, version_string, isMain, - optimize, "", + optimize, NULL, ObjcRunTimeVer); CUCache[FullPath] = WeakVH(NewCU.getNode()); return NewCU; From baldrick at free.fr Sat Nov 14 04:59:38 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 10:59:38 -0000 Subject: [llvm-commits] [dragonegg] r88777 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911141059.nAEAxcuA029663@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 04:59:38 2009 New Revision: 88777 URL: http://llvm.org/viewvc/llvm-project?rev=88777&view=rev Log: Port commit 85982 (evancheng) from llvm-gcc: llvm-gcc is inlining too little at -O2 for C++ code. On WebKit, llvm-gcc compiled code is generally > 20% smaller, but it's > 5% slower. GCC mark all C++ member functions as "inline" and that makes it inline aggressively. After careful consideration, we have decided to increase -O2 inlining limit to 200 for C++ code. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=88777&r1=88776&r2=88777&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Sat Nov 14 04:59:38 2009 @@ -263,11 +263,20 @@ // inliner. gcc has many options that control inlining, but we have decided // not to support anything like that for llvm-gcc. static unsigned GuessAtInliningThreshold() { - unsigned threshold = 200; - if (!flag_inline_functions) + if (optimize_size) // Reduce inline limit. - threshold = 50; - return threshold; + return 50; + + if (optimize >= 3) + return 200; + + // gcc mark C++ member functions "inline" and inline them more aggressively. + // We are not going to do that. Up the inline threshold when compiling for + // C++. + StringRef LanguageName = lang_hooks.name; + if (LanguageName == "GNU C++" || LanguageName == "GNU Objective-C++") + return 200; + return 50; } #ifndef LLVM_TARGET_NAME From baldrick at free.fr Sat Nov 14 05:22:15 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 11:22:15 -0000 Subject: [llvm-commits] [dragonegg] r88778 - in /dragonegg/trunk: darwin/llvm-os.h llvm-backend.cpp Message-ID: <200911141122.nAEBMF9O030330@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 05:22:14 2009 New Revision: 88778 URL: http://llvm.org/viewvc/llvm-project?rev=88778&view=rev Log: Port commit 85992 (void) from llvm-gcc: Reverting r84717. fldry is generating aligned loads of strings. It requires the strings to be 16-byte aligned, which this breaks. Modified: dragonegg/trunk/darwin/llvm-os.h dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/darwin/llvm-os.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/darwin/llvm-os.h?rev=88778&r1=88777&r2=88778&view=diff ============================================================================== --- dragonegg/trunk/darwin/llvm-os.h (original) +++ dragonegg/trunk/darwin/llvm-os.h Sat Nov 14 05:22:14 2009 @@ -42,12 +42,4 @@ argvec.push_back ("--relocation-model=static") #endif /* !TARGET_386 && !TARGET_ARM */ -/* Give a constant string a sufficient alignment for the platform. */ -#define TARGET_ADJUST_CSTRING_ALIGN(GV) \ - do { \ - if (GV->hasInternalLinkage()) { \ - GV->setAlignment(TARGET_64BIT ? 8 : 4); \ - } \ - } while (0) - #endif /* LLVM_OS_H */ Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=88778&r1=88777&r2=88778&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Sat Nov 14 05:22:14 2009 @@ -1210,16 +1210,8 @@ unsigned TargetAlign = getTargetData().getABITypeAlignment(GV->getType()->getElementType()); if (DECL_USER_ALIGN(decl) || - 8 * TargetAlign < (unsigned)DECL_ALIGN(decl)) { + 8 * TargetAlign < (unsigned)DECL_ALIGN(decl)) GV->setAlignment(DECL_ALIGN(decl) / 8); - } -#ifdef TARGET_ADJUST_CSTRING_ALIGN - else if (DECL_INITIAL(decl) != error_mark_node && // uninitialized? - DECL_INITIAL(decl) && - TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) { - TARGET_ADJUST_CSTRING_ALIGN(GV); - } -#endif } // Handle used decls From baldrick at free.fr Sat Nov 14 06:18:36 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:18:36 -0000 Subject: [llvm-commits] [dragonegg] r88780 - /dragonegg/trunk/llvm-types.cpp Message-ID: <200911141218.nAECIbWQ031870@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:18:36 2009 New Revision: 88780 URL: http://llvm.org/viewvc/llvm-project?rev=88780&view=rev Log: Port commit 86012 (lattner) from llvm-gcc: tidy up Modified: dragonegg/trunk/llvm-types.cpp Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=88780&r1=88779&r2=88780&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Sat Nov 14 06:18:36 2009 @@ -609,15 +609,11 @@ /// GetFieldIndex - Returns the index of the LLVM field corresponding to /// this FIELD_DECL, or ~0U if the type the field belongs to has not yet /// been converted. -unsigned int TypeConverter::GetFieldIndex(tree_node *field_decl) { +unsigned int TypeConverter::GetFieldIndex(tree field_decl) { assert(TREE_CODE(field_decl) == FIELD_DECL && "Not a FIELD_DECL!"); std::map::iterator I = FieldIndexMap.find(field_decl); - if (I != FieldIndexMap.end()) { - return I->second; - } else { - assert(false && "Type not laid out for LLVM?"); - return ~0U; - } + assert(I != FieldIndexMap.end() && "Type not laid out for LLVM?"); + return I->second; } /// SetFieldIndex - Set the index of the LLVM field corresponding to From baldrick at free.fr Sat Nov 14 06:21:42 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:21:42 -0000 Subject: [llvm-commits] [dragonegg] r88781 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911141221.nAECLhaa031997@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:21:42 2009 New Revision: 88781 URL: http://llvm.org/viewvc/llvm-project?rev=88781&view=rev Log: Port commit 86138 (dpatel) from llvm-gcc: Enable debug info for global variables. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=88781&r1=88780&r2=88781&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Sat Nov 14 06:21:42 2009 @@ -1241,10 +1241,7 @@ #endif } - // No debug info for globals when optimization is on. While this is - // something that would be accurate and useful to a user, it currently - // affects some optimizations that, e.g., count uses. - if (TheDebugInfo && !optimize) + if (TheDebugInfo) TheDebugInfo->EmitGlobalVariable(GV, decl); TREE_ASM_WRITTEN(decl) = 1; From baldrick at free.fr Sat Nov 14 06:24:10 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:24:10 -0000 Subject: [llvm-commits] [dragonegg] r88782 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911141224.nAECOAFv032074@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:24:09 2009 New Revision: 88782 URL: http://llvm.org/viewvc/llvm-project?rev=88782&view=rev Log: Port commits 86219 and 86220 (evancheng) from llvm-gcc: More code size experimentation shows this is the magical combination: -O3 - 250, -O2 - 200. Remove the C++ hack based on feedback. Oops. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=88782&r1=88781&r2=88782&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Sat Nov 14 06:24:09 2009 @@ -268,15 +268,8 @@ return 50; if (optimize >= 3) - return 200; - - // gcc mark C++ member functions "inline" and inline them more aggressively. - // We are not going to do that. Up the inline threshold when compiling for - // C++. - StringRef LanguageName = lang_hooks.name; - if (LanguageName == "GNU C++" || LanguageName == "GNU Objective-C++") - return 200; - return 50; + return 250; + return 200; } #ifndef LLVM_TARGET_NAME From baldrick at free.fr Sat Nov 14 06:25:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:25:58 -0000 Subject: [llvm-commits] [dragonegg] r88783 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141225.nAECPwuc032127@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:25:58 2009 New Revision: 88783 URL: http://llvm.org/viewvc/llvm-project?rev=88783&view=rev Log: Port commit 86734 (dpatel) from llvm-gcc: Use "" as input file name if stdin is input source. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88783&r1=88782&r2=88783&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 06:25:58 2009 @@ -882,15 +882,22 @@ // code generator accepts maximum one main compile unit per module. If a // module does not contain any main compile unit then the code generator // will emit multiple compile units in the output object file. - getOrCreateCompileUnit(main_input_filename, true); + if (!strcmp (main_input_filename, "")) + getOrCreateCompileUnit("", true); + else + getOrCreateCompileUnit(main_input_filename, true); } /// getOrCreateCompileUnit - Get the compile unit from the cache or /// create a new one if necessary. DICompileUnit DebugInfo::getOrCreateCompileUnit(const char *FullPath, bool isMain) { - if (!FullPath) - FullPath = main_input_filename; + if (!FullPath) { + if (!strcmp (main_input_filename, "")) + FullPath = ""; + else + FullPath = main_input_filename; + } std::map::iterator I = CUCache.find(FullPath); if (I != CUCache.end()) if (Value *M = I->second) From baldrick at free.fr Sat Nov 14 06:33:30 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:33:30 -0000 Subject: [llvm-commits] [dragonegg] r88784 - in /dragonegg/trunk: llvm-convert.cpp llvm-debug.cpp llvm-debug.h Message-ID: <200911141233.nAECXUpe032368@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:33:29 2009 New Revision: 88784 URL: http://llvm.org/viewvc/llvm-project?rev=88784&view=rev Log: Port commit 86749 (dpatel) from llvm-gcc: Attach locatin info with llvm.dbg.declare. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-debug.cpp dragonegg/trunk/llvm-debug.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88784&r1=88783&r2=88784&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Sat Nov 14 06:33:29 2009 @@ -403,7 +403,7 @@ TheDebugInfo->EmitDeclare(ResultDecl, dwarf::DW_TAG_return_variable, "agg.result", RetTy, Tmp, - Builder.GetInsertBlock()); + Builder); } ++AI; } @@ -709,7 +709,7 @@ if (!isInvRef && TheDebugInfo) TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable, Name, TREE_TYPE(Args), - AI, Builder.GetInsertBlock()); + AI, Builder); ++AI; } else { // Otherwise, we create an alloca to hold the argument value and provide @@ -721,7 +721,7 @@ if (TheDebugInfo) { TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable, Name, TREE_TYPE(Args), Tmp, - Builder.GetInsertBlock()); + Builder); } // Emit annotate intrinsic if arg has annotate attr @@ -755,6 +755,9 @@ // Not supported yet. } + if (TheDebugInfo) + TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder); + // Create a new block for the return node, but don't insert it yet. ReturnBB = BasicBlock::Create(Context, "return"); } @@ -1825,11 +1828,11 @@ if (DECL_NAME(decl)) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_auto_variable, AI->getName(), TREE_TYPE(decl), AI, - Builder.GetInsertBlock()); + Builder); } else if (TREE_CODE(decl) == RESULT_DECL) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_return_variable, AI->getName(), TREE_TYPE(decl), AI, - Builder.GetInsertBlock()); + Builder); } } } Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88784&r1=88783&r2=88784&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 06:33:29 2009 @@ -302,7 +302,8 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." void DebugInfo::EmitDeclare(tree decl, unsigned Tag, StringRef Name, - tree type, Value *AI, BasicBlock *CurBB) { + tree type, Value *AI, + LLVMBuilder &Builder) { // Do not emit variable declaration info, for now. if (optimize) @@ -323,7 +324,9 @@ Loc.line, getOrCreateType(type)); // Insert an llvm.dbg.declare into the current block. - DebugFactory.InsertDeclare(AI, D, CurBB); + Instruction *Call = DebugFactory.InsertDeclare(AI, D, + Builder.GetInsertBlock()); + Builder.SetDebugLocation(Call); } /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of Modified: dragonegg/trunk/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.h?rev=88784&r1=88783&r2=88784&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.h (original) +++ dragonegg/trunk/llvm-debug.h Sat Nov 14 06:33:29 2009 @@ -88,8 +88,7 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." void EmitDeclare(tree_node *decl, unsigned Tag, StringRef Name, - tree_node *type, Value *AI, - BasicBlock *CurBB); + tree_node *type, Value *AI, LLVMBuilder &Builder); /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of /// source line. From baldrick at free.fr Sat Nov 14 06:34:44 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:34:44 -0000 Subject: [llvm-commits] [dragonegg] r88785 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141234.nAECYibs032459@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:34:44 2009 New Revision: 88785 URL: http://llvm.org/viewvc/llvm-project?rev=88785&view=rev Log: Port commit 86860 (dpatel) from llvm-gcc: Create new location to attach with llvm.dbg.declare. This location is only used to find the context of the variable by the code generator. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88785&r1=88784&r2=88785&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 06:34:44 2009 @@ -326,7 +326,15 @@ // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); - Builder.SetDebugLocation(Call); + +#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN + llvm::DIDescriptor DR = RegionStack.back(); + llvm::DIScope DS = llvm::DIScope(DR.getNode()); + llvm::DILocation DO(NULL); + llvm::DILocation DL = + DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); + Builder.SetDebugLocation(Call, DL.getNode()); +#endif } /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of From baldrick at free.fr Sat Nov 14 06:36:07 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:36:07 -0000 Subject: [llvm-commits] [dragonegg] r88786 - /dragonegg/trunk/llvm-abi.h Message-ID: <200911141236.nAECa77U032529@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:36:07 2009 New Revision: 88786 URL: http://llvm.org/viewvc/llvm-project?rev=88786&view=rev Log: Port commit 86892 (bwilson) from llvm-gcc: Fix pr5406: When passing an aggregate in integer registers, the data cannot be split up into integer types smaller than the target registers. Most of the data is put into an array of i32 or i64 values, and that part is OK. But, if the size is not a multiple of 32 or 64, there may be some leftover bytes to be passed separately. Change to pass those leftover bytes in a single integer. The x86_64 target already does this in target-specific code. This also fixes radars 7226380 and 7226213. Modified: dragonegg/trunk/llvm-abi.h Modified: dragonegg/trunk/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88786&r1=88785&r2=88786&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi.h (original) +++ dragonegg/trunk/llvm-abi.h Sat Nov 14 06:36:07 2009 @@ -630,19 +630,18 @@ Elts.push_back(ATy); } - if (Size >= 4) { + // Put any left over bytes into one last register. This target-independent + // code does not know the size of the argument registers, so use the + // smallest size that will work. + if (Size > 4) { + Elts.push_back(Type::getInt64Ty(getGlobalContext())); + } else if (Size > 2) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { + } else if (Size > 1) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { + } else { Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; } - assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1077,19 +1076,18 @@ Elts.push_back(ATy); } - if (Size >= 4) { + // Put any left over bytes into one last register. This target-independent + // code does not know the size of the argument registers, so use the + // smallest size that will work. + if (Size > 4) { + Elts.push_back(Type::getInt64Ty(getGlobalContext())); + } else if (Size > 2) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { + } else if (Size > 1) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { + } else { Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; } - assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; From baldrick at free.fr Sat Nov 14 06:37:45 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:37:45 -0000 Subject: [llvm-commits] [dragonegg] r88787 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141237.nAECbjNW032588@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:37:45 2009 New Revision: 88787 URL: http://llvm.org/viewvc/llvm-project?rev=88787&view=rev Log: Port commit 86916 (dpatel) from llvm-gcc: Do not use StringRef while using DebugInfo interface. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88787&r1=88786&r2=88787&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 06:37:45 2009 @@ -375,15 +375,14 @@ // Gather location information. expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl)); DIType TyD = getOrCreateType(TREE_TYPE(decl)); - std::string DispName = GV->getNameStr(); + const char *DispName = GV->getNameStr().c_str(); if (DECL_NAME(decl)) { if (IDENTIFIER_POINTER(DECL_NAME(decl))) DispName = IDENTIFIER_POINTER(DECL_NAME(decl)); } DebugFactory.CreateGlobalVariable(getOrCreateCompileUnit(Loc.file), - GV->getNameStr(), - DispName, + DispName, DispName, getLinkageName(decl), getOrCreateCompileUnit(Loc.file), Loc.line, TyD, GV->hasInternalLinkage(), @@ -624,7 +623,7 @@ llvm::DICompositeType FwdDecl = DebugFactory.CreateCompositeType(Tag, findRegion(type), - FwdName, + FwdName.c_str(), getOrCreateCompileUnit(Loc.file), Loc.line, 0, 0, 0, Flags, @@ -946,8 +945,8 @@ unsigned ObjcRunTimeVer = 0; // if (flag_objc_abi != 0 && flag_objc_abi != -1) // ObjcRunTimeVer = flag_objc_abi; - DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName, - Directory, + DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(), + Directory.c_str(), version_string, isMain, optimize, NULL, ObjcRunTimeVer); From baldrick at free.fr Sat Nov 14 06:41:17 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:41:17 -0000 Subject: [llvm-commits] [dragonegg] r88788 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141241.nAECfHtt032714@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:41:17 2009 New Revision: 88788 URL: http://llvm.org/viewvc/llvm-project?rev=88788&view=rev Log: Port commit 87008 (dpatel) from llvm-gcc: "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for locations and types. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88788&r1=88787&r2=88788&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 06:41:17 2009 @@ -243,9 +243,6 @@ Fn->hasInternalLinkage(), true /*definition*/); -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - DebugFactory.InsertSubprogramStart(SP, CurBB); -#endif // Push function on region stack. RegionStack.push_back(SP); RegionMap[FnDecl] = SP; @@ -286,9 +283,6 @@ /// region - "llvm.dbg.region.end." void DebugInfo::EmitFunctionEnd(BasicBlock *CurBB, bool EndFunction) { assert(!RegionStack.empty() && "Region stack mismatch, stack empty!"); -#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN - DebugFactory.InsertRegionEnd(RegionStack.back(), CurBB); -#endif RegionStack.pop_back(); // Blocks get erased; clearing these is needed for determinism, and also // a good idea if the next function gets inlined. @@ -327,14 +321,12 @@ Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - llvm::DIDescriptor DR = RegionStack.back(); - llvm::DIScope DS = llvm::DIScope(DR.getNode()); - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); - Builder.SetDebugLocation(Call, DL.getNode()); -#endif + llvm::DIDescriptor DR = RegionStack.back(); + llvm::DIScope DS = llvm::DIScope(DR.getNode()); + llvm::DILocation DO(NULL); + llvm::DILocation DL = + DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); + Builder.SetDebugLocation(Call, DL.getNode()); } /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of @@ -353,7 +345,6 @@ PrevLineNo = CurLineNo; PrevBB = CurBB; -#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN if (RegionStack.empty()) return; llvm::DIDescriptor DR = RegionStack.back(); @@ -362,11 +353,6 @@ llvm::DILocation DL = DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); Builder.SetCurrentDebugLocation(DL.getNode()); -#else - DebugFactory.InsertStopPoint(getOrCreateCompileUnit(CurFullPath), - CurLineNo, 0 /*column no. */, - CurBB); -#endif } /// EmitGlobalVariable - Emit information about a global variable. From baldrick at free.fr Sat Nov 14 06:42:06 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 12:42:06 -0000 Subject: [llvm-commits] [dragonegg] r88789 - /dragonegg/trunk/llvm-abi.h Message-ID: <200911141242.nAECg6OD032749@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 06:42:06 2009 New Revision: 88789 URL: http://llvm.org/viewvc/llvm-project?rev=88789&view=rev Log: Port commit 87052 (bwilson) from llvm-gcc: Revert 86892. Modified: dragonegg/trunk/llvm-abi.h Modified: dragonegg/trunk/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88789&r1=88788&r2=88789&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi.h (original) +++ dragonegg/trunk/llvm-abi.h Sat Nov 14 06:42:06 2009 @@ -630,18 +630,19 @@ Elts.push_back(ATy); } - // Put any left over bytes into one last register. This target-independent - // code does not know the size of the argument registers, so use the - // smallest size that will work. - if (Size > 4) { - Elts.push_back(Type::getInt64Ty(getGlobalContext())); - } else if (Size > 2) { + if (Size >= 4) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - } else if (Size > 1) { + Size -= 4; + } + if (Size >= 2) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - } else { + Size -= 2; + } + if (Size >= 1) { Elts.push_back(Type::getInt8Ty(getGlobalContext())); + Size -= 1; } + assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1076,18 +1077,19 @@ Elts.push_back(ATy); } - // Put any left over bytes into one last register. This target-independent - // code does not know the size of the argument registers, so use the - // smallest size that will work. - if (Size > 4) { - Elts.push_back(Type::getInt64Ty(getGlobalContext())); - } else if (Size > 2) { + if (Size >= 4) { Elts.push_back(Type::getInt32Ty(getGlobalContext())); - } else if (Size > 1) { + Size -= 4; + } + if (Size >= 2) { Elts.push_back(Type::getInt16Ty(getGlobalContext())); - } else { + Size -= 2; + } + if (Size >= 1) { Elts.push_back(Type::getInt8Ty(getGlobalContext())); + Size -= 1; } + assert(Size == 0 && "Didn't cover value?"); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; From baldrick at free.fr Sat Nov 14 08:10:09 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 14:10:09 -0000 Subject: [llvm-commits] [dragonegg] r88790 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200911141410.nAEEA9rP003630@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 08:10:09 2009 New Revision: 88790 URL: http://llvm.org/viewvc/llvm-project?rev=88790&view=rev Log: Port commit 88701 (dpatel) from llvm-gcc: Avoid using c_str() on temp. string. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88790&r1=88789&r2=88790&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 08:10:09 2009 @@ -361,7 +361,8 @@ // Gather location information. expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl)); DIType TyD = getOrCreateType(TREE_TYPE(decl)); - const char *DispName = GV->getNameStr().c_str(); + std::string DispNameStr = GV->getNameStr(); + const char *DispName = DispNameStr.c_str(); if (DECL_NAME(decl)) { if (IDENTIFIER_POINTER(DECL_NAME(decl))) DispName = IDENTIFIER_POINTER(DECL_NAME(decl)); From benny.kra at googlemail.com Sat Nov 14 08:14:59 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 Nov 2009 14:14:59 -0000 Subject: [llvm-commits] [llvm] r88791 - in /llvm/trunk/include/llvm/Support: Compiler.h ErrorHandling.h Message-ID: <200911141414.nAEEExvC003764@zion.cs.uiuc.edu> Author: d0k Date: Sat Nov 14 08:14:58 2009 New Revision: 88791 URL: http://llvm.org/viewvc/llvm-project?rev=88791&view=rev Log: Make NORETURN working with MSVC. MSVC only accepts NORETURN in front of the decl so move it there. GCC accepts it both in front and after decls. Modified: llvm/trunk/include/llvm/Support/Compiler.h llvm/trunk/include/llvm/Support/ErrorHandling.h Modified: llvm/trunk/include/llvm/Support/Compiler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=88791&r1=88790&r2=88791&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h (original) +++ llvm/trunk/include/llvm/Support/Compiler.h Sat Nov 14 08:14:58 2009 @@ -58,6 +58,8 @@ #ifdef __GNUC__ #define NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define NORETURN __declspec(noreturn) #else #define NORETURN #endif Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=88791&r1=88790&r2=88791&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ErrorHandling.h (original) +++ llvm/trunk/include/llvm/Support/ErrorHandling.h Sat Nov 14 08:14:58 2009 @@ -60,15 +60,15 @@ /// standard error, followed by a newline. /// After the error handler is called this function will call exit(1), it /// does not return. - void llvm_report_error(const char *reason) NORETURN; - void llvm_report_error(const std::string &reason) NORETURN; - void llvm_report_error(const Twine &reason) NORETURN; + NORETURN void llvm_report_error(const char *reason); + NORETURN void llvm_report_error(const std::string &reason); + NORETURN void llvm_report_error(const Twine &reason); /// This function calls abort(), and prints the optional message to stderr. /// Use the llvm_unreachable macro (that adds location info), instead of /// calling this function directly. - void llvm_unreachable_internal(const char *msg=0, const char *file=0, - unsigned line=0) NORETURN; + NORETURN void llvm_unreachable_internal(const char *msg=0, + const char *file=0, unsigned line=0); } /// Prints the message and location info to stderr in !NDEBUG builds. From benny.kra at googlemail.com Sat Nov 14 08:35:33 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 Nov 2009 15:35:33 +0100 Subject: [llvm-commits] [llvm] r88725 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/SlotIndexes.cpp lib/CodeGen/Spiller.cpp In-Reply-To: <200911140002.nAE02q3F027475@zion.cs.uiuc.edu> References: <200911140002.nAE02q3F027475@zion.cs.uiuc.edu> Message-ID: Am 14.11.2009 um 01:02 schrieb Lang Hames: > Author: lhames > Date: Fri Nov 13 18:02:51 2009 > New Revision: 88725 > > URL: http://llvm.org/viewvc/llvm-project?rev=88725&view=rev > Log: > Added an API to the SlotIndexes pass to allow new instructions to be inserted into the numbering. > > PreAllocSplitting is now using this API to insert code. Hi Lang, one comment below > Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=88725&r1=88724&r2=88725&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) > +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Fri Nov 13 18:02:51 2009 > @@ -487,7 +487,7 @@ > void dump() const; > > /// Renumber the index list, providing space for new instructions. > - void renumber(); > + void renumberIndexes(); > > /// Returns the zero index for this analysis. > SlotIndex getZeroIndex() { > @@ -647,99 +647,89 @@ > return 0; > } > > - /// Returns true if there is a gap in the numbering before the given index. > - bool hasGapBeforeInstr(SlotIndex index) { > - index = index.getBaseIndex(); > - SlotIndex prevIndex = index.getPrevIndex(); > - > - if (prevIndex == getZeroIndex()) > - return false; > - > - if (getInstructionFromIndex(prevIndex) == 0) > - return true; > - > - if (prevIndex.distance(index) >= 2 * SlotIndex::NUM) > - return true; > - > - return false; > - } > - > - /// Returns true if there is a gap in the numbering after the given index. > - bool hasGapAfterInstr(SlotIndex index) const { > - // Not implemented yet. > - assert(false && > - "SlotIndexes::hasGapAfterInstr(SlotIndex) not implemented yet."); > - return false; > - } > - > - /// findGapBeforeInstr - Find an empty instruction slot before the > - /// specified index. If "Furthest" is true, find one that's furthest > - /// away from the index (but before any index that's occupied). > - // FIXME: This whole method should go away in future. It should > - // always be possible to insert code between existing indices. > - SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) { > - if (index == getZeroIndex()) > - return getInvalidIndex(); > - > - index = index.getBaseIndex(); > - SlotIndex prevIndex = index.getPrevIndex(); > - > - if (prevIndex == getZeroIndex()) > - return getInvalidIndex(); > - > - // Try to reuse existing index objects with null-instrs. > - if (getInstructionFromIndex(prevIndex) == 0) { > - if (furthest) { > - while (getInstructionFromIndex(prevIndex) == 0 && > - prevIndex != getZeroIndex()) { > - prevIndex = prevIndex.getPrevIndex(); > - } > - > - prevIndex = prevIndex.getNextIndex(); > - } > - > - assert(getInstructionFromIndex(prevIndex) == 0 && "Index list is broken."); > - > - return prevIndex; > + /// Insert the given machine instruction into the mapping. Returns the > + /// assigned index. > + SlotIndex insertMachineInstrInMaps(MachineInstr *mi, > + bool *deferredRenumber = 0) { > + assert(mi2iMap.find(mi) == mi2iMap.end() && "Instr already indexed."); > + > + MachineBasicBlock *mbb = mi->getParent(); > + > + assert(mbb != 0 && "Instr must be added to function."); > + > + MBB2IdxMap::iterator mbbRangeItr = mbb2IdxMap.find(mbb); > + > + assert(mbbRangeItr != mbb2IdxMap.end() && > + "Instruction's parent MBB has not been added to SlotIndexes."); > + > + MachineBasicBlock::iterator miItr(mi); > + bool needRenumber = false; > + IndexListEntry *newEntry; > + > + IndexListEntry *prevEntry; > + if (miItr == mbb->begin()) { > + // If mi is at the mbb beginning, get the prev index from the mbb. > + prevEntry = &mbbRangeItr->second.first.entry(); > + } else { > + // Otherwise get it from the previous instr. > + MachineBasicBlock::iterator pItr(prior(miItr)); > + prevEntry = &getInstructionIndex(pItr).entry(); > } > > - int dist = prevIndex.distance(index); > + // Get next entry from previous entry. > + IndexListEntry *nextEntry = prevEntry->getNext(); > + > + // Get a number for the new instr, or 0 if there's no room currently. > + // In the latter case we'll force a renumber later. > + unsigned dist = nextEntry->getIndex() - prevEntry->getIndex(); > + unsigned newNumber = dist > SlotIndex::NUM ? > + prevEntry->getIndex() + ((dist >> 1) & ~3U) : 0; > > - // Double check that the spacing between this instruction and > - // the last is sane. > - assert(dist >= SlotIndex::NUM && > - "Distance between indexes too small."); > - > - // If there's no gap return an invalid index. > - if (dist < 2*SlotIndex::NUM) { > - return getInvalidIndex(); > + if (newNumber == 0) { > + needRenumber = true; > } > > - // Otherwise insert new index entries into the list using the > - // gap in the numbering. > - IndexListEntry *newEntry = > - createEntry(0, prevIndex.entry().getIndex() + SlotIndex::NUM); > + // Insert a new list entry for mi. > + newEntry = createEntry(mi, newNumber); > + insert(nextEntry, newEntry); > + > + SlotIndex newIndex(newEntry, SlotIndex::LOAD); > + mi2iMap.insert(std::make_pair(mi, newIndex)); > + > + if (miItr == mbb->end()) { > + // If this is the last instr in the MBB then we need to fix up the bb > + // range: > + mbbRangeItr->second.second = SlotIndex(newIndex, SlotIndex::STORE); MSVC warns: SlotIndexes.h(702) : warning C4305: 'argument' : truncation from 'llvm::SlotIndex::Slot' to 'bool' I don't think this code is doing what you intended it to. > + } > > - insert(&index.entry(), newEntry); > + // Renumber if we need to. > + if (needRenumber) { > + if (deferredRenumber == 0) > + renumberIndexes(); > + else > + *deferredRenumber = true; > + } > > - // And return a pointer to the entry at the start of the gap. > - return index.getPrevIndex(); > + return newIndex; > } > > - /// Insert the given machine instruction into the mapping at the given > - /// index. > - void insertMachineInstrInMaps(MachineInstr *mi, SlotIndex index) { > - index = index.getBaseIndex(); > - IndexListEntry *miEntry = &index.entry(); > - assert(miEntry->getInstr() == 0 && "Index already in use."); > - miEntry->setInstr(mi); > - > - assert(mi2iMap.find(mi) == mi2iMap.end() && > - "MachineInstr already has an index."); > + /// Add all instructions in the vector to the index list. This method will > + /// defer renumbering until all instrs have been added, and should be > + /// preferred when adding multiple instrs. > + void insertMachineInstrsInMaps(SmallVectorImpl &mis) { > + bool renumber = false; > + > + for (SmallVectorImpl::iterator > + miItr = mis.begin(), miEnd = mis.end(); > + miItr != miEnd; ++miItr) { > + insertMachineInstrInMaps(*miItr, &renumber); > + } > > - mi2iMap.insert(std::make_pair(mi, index)); > + if (renumber) > + renumberIndexes(); > } > > + > /// Remove the given machine instruction from the mapping. > void removeMachineInstrFromMaps(MachineInstr *mi) { > // remove index -> MachineInstr and From benny.kra at googlemail.com Sat Nov 14 09:15:39 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 Nov 2009 15:15:39 -0000 Subject: [llvm-commits] [llvm] r88794 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200911141515.nAEFFdoW005557@zion.cs.uiuc.edu> Author: d0k Date: Sat Nov 14 09:15:39 2009 New Revision: 88794 URL: http://llvm.org/viewvc/llvm-project?rev=88794&view=rev Log: This test doesn't work on arm either. Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=88794&r1=88793&r2=88794&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Sat Nov 14 09:15:39 2009 @@ -458,9 +458,7 @@ NumTablesDeallocated); } -#if !defined(__APPLE__) || \ - !(defined(__POWERPC__) || defined (__ppc__) || \ - defined(_POWER) || defined(_ARCH_PPC)) +#if !defined(__arm__) && !defined(__powerpc__) && !defined(__ppc__) typedef int (*FooPtr) (); TEST_F(JITTest, NoStubs) { From baldrick at free.fr Sat Nov 14 10:14:30 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 16:14:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r88796 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <200911141614.nAEGEUmr007381@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 10:14:29 2009 New Revision: 88796 URL: http://llvm.org/viewvc/llvm-project?rev=88796&view=rev Log: Sync with dragonegg: use isVoidTy() predicate rather than comparing with void type. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=88796&r1=88795&r2=88796&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Sat Nov 14 10:14:29 2009 @@ -699,7 +699,7 @@ } } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { - if (OrigElts[i] != Type::getVoidTy(getGlobalContext())) { + if (!OrigElts[i]->isVoidTy()) { C.EnterField(i, STy); unsigned RealSize = 0; if (LastEltSizeDiff && i == (e - 1)) @@ -1145,7 +1145,7 @@ } } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { - if (OrigElts[i] != Type::getVoidTy(getGlobalContext())) { + if (!OrigElts[i]->isVoidTy()) { C.EnterField(i, STy); unsigned RealSize = 0; if (LastEltSizeDiff && i == (e - 1)) From benny.kra at googlemail.com Sat Nov 14 10:37:18 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 Nov 2009 16:37:18 -0000 Subject: [llvm-commits] [llvm] r88798 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h include/llvm/Support/Compiler.h lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp utils/TableGen/DAGISelEmitter.cpp Message-ID: <200911141637.nAEGbJHP008134@zion.cs.uiuc.edu> Author: d0k Date: Sat Nov 14 10:37:18 2009 New Revision: 88798 URL: http://llvm.org/viewvc/llvm-project?rev=88798&view=rev Log: Implement DISABLE_INLINE for MSVC. This required changing the position in all forward declaration and patching tblgen to emit it right. Patch by Amine Khaldi! Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/include/llvm/Support/Compiler.h llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=88798&r1=88797&r2=88798&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Sat Nov 14 10:37:18 2009 @@ -64,22 +64,22 @@ /// ReplaceUses - replace all uses of the old node F with the use /// of the new node T. -void ReplaceUses(SDValue F, SDValue T) DISABLE_INLINE { +DISABLE_INLINE void ReplaceUses(SDValue F, SDValue T) { ISelUpdater ISU(ISelPosition); CurDAG->ReplaceAllUsesOfValueWith(F, T, &ISU); } /// ReplaceUses - replace all uses of the old nodes F with the use /// of the new nodes T. -void ReplaceUses(const SDValue *F, const SDValue *T, - unsigned Num) DISABLE_INLINE { +DISABLE_INLINE void ReplaceUses(const SDValue *F, const SDValue *T, + unsigned Num) { ISelUpdater ISU(ISelPosition); CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISU); } /// ReplaceUses - replace all uses of the old node F with the use /// of the new node T. -void ReplaceUses(SDNode *F, SDNode *T) DISABLE_INLINE { +DISABLE_INLINE void ReplaceUses(SDNode *F, SDNode *T) { ISelUpdater ISU(ISelPosition); CurDAG->ReplaceAllUsesWith(F, T, &ISU); } Modified: llvm/trunk/include/llvm/Support/Compiler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=88798&r1=88797&r2=88798&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h (original) +++ llvm/trunk/include/llvm/Support/Compiler.h Sat Nov 14 10:37:18 2009 @@ -52,6 +52,8 @@ // method "not for inlining". #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) #define DISABLE_INLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +#define DISABLE_INLINE __declspec(noinline) #else #define DISABLE_INLINE #endif Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp?rev=88798&r1=88797&r2=88798&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp Sat Nov 14 10:37:18 2009 @@ -35,7 +35,7 @@ extern "C" { // Debuggers puts a breakpoint in this function. - void DISABLE_INLINE __jit_debug_register_code() { } + DISABLE_INLINE void __jit_debug_register_code() { } // We put information about the JITed function in this global, which the // debugger reads. Make sure to specify the version statically, because the Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=88798&r1=88797&r2=88798&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Sat Nov 14 10:37:18 2009 @@ -1786,11 +1786,7 @@ } CallerCode += ");"; - CalleeCode += ") "; - // Prevent emission routines from being inlined to reduce selection - // routines stack frame sizes. - CalleeCode += "DISABLE_INLINE "; - CalleeCode += "{\n"; + CalleeCode += ") {\n"; for (std::vector::const_reverse_iterator I = AddedInits.rbegin(), E = AddedInits.rend(); I != E; ++I) @@ -1811,6 +1807,9 @@ } else { EmitFuncNum = EmitFunctions.size(); EmitFunctions.insert(std::make_pair(CalleeCode, EmitFuncNum)); + // Prevent emission routines from being inlined to reduce selection + // routines stack frame sizes. + OS << "DISABLE_INLINE "; OS << "SDNode *Emit_" << utostr(EmitFuncNum) << CalleeCode; } From baldrick at free.fr Sat Nov 14 10:42:48 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 14 Nov 2009 16:42:48 -0000 Subject: [llvm-commits] [dragonegg] r88799 - in /dragonegg/trunk: llvm-convert.cpp llvm-debug.cpp llvm-debug.h Message-ID: <200911141642.nAEGgmXi008296@zion.cs.uiuc.edu> Author: baldrick Date: Sat Nov 14 10:42:47 2009 New Revision: 88799 URL: http://llvm.org/viewvc/llvm-project?rev=88799&view=rev Log: Complete sync with llvm-gcc revision 88701: port some llvm-gcc changes that I missed somehow. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-debug.cpp dragonegg/trunk/llvm-debug.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88799&r1=88798&r2=88799&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Sat Nov 14 10:42:47 2009 @@ -1827,11 +1827,11 @@ if (TheDebugInfo) { if (DECL_NAME(decl)) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_auto_variable, - AI->getName(), TREE_TYPE(decl), AI, + AI->getNameStr().c_str(), TREE_TYPE(decl), AI, Builder); } else if (TREE_CODE(decl) == RESULT_DECL) { TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_return_variable, - AI->getName(), TREE_TYPE(decl), AI, + AI->getNameStr().c_str(), TREE_TYPE(decl), AI, Builder); } } Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=88799&r1=88798&r2=88799&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Sat Nov 14 10:42:47 2009 @@ -295,7 +295,7 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." -void DebugInfo::EmitDeclare(tree decl, unsigned Tag, StringRef Name, +void DebugInfo::EmitDeclare(tree decl, unsigned Tag, const char *Name, tree type, Value *AI, LLVMBuilder &Builder) { Modified: dragonegg/trunk/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.h?rev=88799&r1=88798&r2=88799&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.h (original) +++ dragonegg/trunk/llvm-debug.h Sat Nov 14 10:42:47 2009 @@ -87,7 +87,7 @@ /// EmitDeclare - Constructs the debug code for allocation of a new variable. /// region - "llvm.dbg.declare." - void EmitDeclare(tree_node *decl, unsigned Tag, StringRef Name, + void EmitDeclare(tree_node *decl, unsigned Tag, const char *Name, tree_node *type, Value *AI, LLVMBuilder &Builder); /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of From asl at math.spbu.ru Sat Nov 14 12:01:43 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 14 Nov 2009 18:01:43 -0000 Subject: [llvm-commits] [llvm] r88800 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200911141801.nAEI1hqo010762@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 14 12:01:41 2009 New Revision: 88800 URL: http://llvm.org/viewvc/llvm-project?rev=88800&view=rev Log: Temporary disable the error - it seems to be too conservative. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=88800&r1=88799&r2=88800&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Sat Nov 14 12:01:41 2009 @@ -459,12 +459,13 @@ RealignStack && (MFI->getMaxAlignment() > StackAlign); // FIXME: Currently we don't support stack realignment for functions with - // variable-sized allocas - if (requiresRealignment && MFI->hasVarSizedObjects()) + // variable-sized allocas. + // FIXME: Temporary disable the error - it seems to be too conservative. + if (0 && requiresRealignment && MFI->hasVarSizedObjects()) llvm_report_error( "Stack realignment in presense of dynamic allocas is not supported"); - return requiresRealignment; + return (requiresRealignment && !MFI->hasVarSizedObjects()); } bool X86RegisterInfo::hasReservedCallFrame(MachineFunction &MF) const { From richard at xmos.com Sat Nov 14 13:33:35 2009 From: richard at xmos.com (Richard Osborne) Date: Sat, 14 Nov 2009 19:33:35 -0000 Subject: [llvm-commits] [llvm] r88802 - in /llvm/trunk: lib/Target/XCore/XCoreISelLowering.cpp lib/Target/XCore/XCoreISelLowering.h test/CodeGen/XCore/bigstructret.ll Message-ID: <200911141933.nAEJXZnL013636@zion.cs.uiuc.edu> Author: friedgold Date: Sat Nov 14 13:33:35 2009 New Revision: 88802 URL: http://llvm.org/viewvc/llvm-project?rev=88802&view=rev Log: Add XCore support for arbitrary-sized aggregate returns. Added: llvm/trunk/test/CodeGen/XCore/bigstructret.ll Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=88802&r1=88801&r2=88802&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Sat Nov 14 13:33:35 2009 @@ -918,6 +918,17 @@ // Return Value Calling Convention Implementation //===----------------------------------------------------------------------===// +bool XCoreTargetLowering:: +CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, + const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + SelectionDAG &DAG) { + SmallVector RVLocs; + CCState CCInfo(CallConv, isVarArg, getTargetMachine(), + RVLocs, *DAG.getContext()); + return CCInfo.CheckReturn(OutTys, ArgsFlags, RetCC_XCore); +} + SDValue XCoreTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.h?rev=88802&r1=88801&r2=88802&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.h (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Sat Nov 14 13:33:35 2009 @@ -159,6 +159,12 @@ CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl &Outs, DebugLoc dl, SelectionDAG &DAG); + + virtual bool + CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, + const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + SelectionDAG &DAG); }; } Added: llvm/trunk/test/CodeGen/XCore/bigstructret.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/bigstructret.ll?rev=88802&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/XCore/bigstructret.ll (added) +++ llvm/trunk/test/CodeGen/XCore/bigstructret.ll Sat Nov 14 13:33:35 2009 @@ -0,0 +1,43 @@ +; RUN: llc < %s -march=xcore | FileCheck %s + +%0 = type { i32, i32, i32, i32 } +%1 = type { i32, i32, i32, i32, i32 } + +; Structs of 4 words can be returned in registers +define internal fastcc %0 @ReturnBigStruct() nounwind readnone { +entry: + %0 = insertvalue %0 zeroinitializer, i32 12, 0 + %1 = insertvalue %0 %0, i32 24, 1 + %2 = insertvalue %0 %1, i32 48, 2 + %3 = insertvalue %0 %2, i32 24601, 3 + ret %0 %3 +} +; CHECK: ReturnBigStruct: +; CHECK: ldc r0, 12 +; CHECK: ldc r1, 24 +; CHECK: ldc r2, 48 +; CHECK: ldc r3, 24601 +; CHECK: retsp 0 + +; Structs bigger than 4 words are returned via a hidden hidden sret-parameter +define internal fastcc %1 @ReturnBigStruct2() nounwind readnone { +entry: + %0 = insertvalue %1 zeroinitializer, i32 12, 0 + %1 = insertvalue %1 %0, i32 24, 1 + %2 = insertvalue %1 %1, i32 48, 2 + %3 = insertvalue %1 %2, i32 24601, 3 + %4 = insertvalue %1 %3, i32 4321, 4 + ret %1 %4 +} +; CHECK: ReturnBigStruct2: +; CHECK: ldc r1, 4321 +; CHECK: stw r1, r0[4] +; CHECK: ldc r1, 24601 +; CHECK: stw r1, r0[3] +; CHECK: ldc r1, 48 +; CHECK: stw r1, r0[2] +; CHECK: ldc r1, 24 +; CHECK: stw r1, r0[1] +; CHECK: ldc r1, 12 +; CHECK: stw r1, r0[0] +; CHECK: retsp 0 From benny.kra at googlemail.com Sat Nov 14 13:51:20 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 Nov 2009 19:51:20 -0000 Subject: [llvm-commits] [llvm] r88803 - /llvm/trunk/include/llvm/Analysis/Dominators.h Message-ID: <200911141951.nAEJpKQL014259@zion.cs.uiuc.edu> Author: d0k Date: Sat Nov 14 13:51:20 2009 New Revision: 88803 URL: http://llvm.org/viewvc/llvm-project?rev=88803&view=rev Log: Remove dead variable found by clang++. Modified: llvm/trunk/include/llvm/Analysis/Dominators.h Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=88803&r1=88802&r2=88803&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Sat Nov 14 13:51:20 2009 @@ -310,7 +310,6 @@ if (DomTreeNodes.size() != OtherDomTreeNodes.size()) return true; - SmallPtrSet MyBBs; for (typename DomTreeNodeMapType::const_iterator I = this->DomTreeNodes.begin(), E = this->DomTreeNodes.end(); I != E; ++I) { From grosbach at apple.com Sat Nov 14 14:09:13 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 20:09:13 -0000 Subject: [llvm-commits] [llvm] r88804 - in /llvm/trunk: include/llvm/CodeGen/MachineJumpTableInfo.h lib/CodeGen/MachineFunction.cpp Message-ID: <200911142009.nAEK9DDI014736@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 14 14:09:13 2009 New Revision: 88804 URL: http://llvm.org/viewvc/llvm-project?rev=88804&view=rev Log: Add function to replace a destination MBB in a single jump table Modified: llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h llvm/trunk/lib/CodeGen/MachineFunction.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h?rev=88804&r1=88803&r2=88804&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h Sat Nov 14 14:09:13 2009 @@ -69,6 +69,11 @@ /// the jump tables to branch to New instead. bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New); + /// ReplaceMBBInJumpTable - If Old is a target of the jump tables, update + /// the jump table to branch to New instead. + bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, + MachineBasicBlock *New); + /// getEntrySize - Returns the size of an individual field in a jump table. /// unsigned getEntrySize() const { return EntrySize; } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=88804&r1=88803&r2=88804&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Nov 14 14:09:13 2009 @@ -545,14 +545,25 @@ MachineBasicBlock *New) { assert(Old != New && "Not making a change?"); bool MadeChange = false; - for (size_t i = 0, e = JumpTables.size(); i != e; ++i) { - MachineJumpTableEntry &JTE = JumpTables[i]; - for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j) - if (JTE.MBBs[j] == Old) { - JTE.MBBs[j] = New; - MadeChange = true; - } - } + for (size_t i = 0, e = JumpTables.size(); i != e; ++i) + ReplaceMBBInJumpTable(i, Old, New); + return MadeChange; +} + +/// ReplaceMBBInJumpTable - If Old is a target of the jump tables, update +/// the jump table to branch to New instead. +bool +MachineJumpTableInfo::ReplaceMBBInJumpTable(unsigned Idx, + MachineBasicBlock *Old, + MachineBasicBlock *New) { + assert(Old != New && "Not making a change?"); + bool MadeChange = false; + MachineJumpTableEntry &JTE = JumpTables[Idx]; + for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j) + if (JTE.MBBs[j] == Old) { + JTE.MBBs[j] = New; + MadeChange = true; + } return MadeChange; } From grosbach at apple.com Sat Nov 14 14:10:18 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 20:10:18 -0000 Subject: [llvm-commits] [llvm] r88805 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911142010.nAEKAIMp014778@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 14 14:10:18 2009 New Revision: 88805 URL: http://llvm.org/viewvc/llvm-project?rev=88805&view=rev Log: Cleanup flow, and only update the jump table we're analyzing when replacing a destination MBB. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=88805&r1=88804&r2=88805&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Sat Nov 14 14:10:18 2009 @@ -1749,7 +1749,7 @@ MachineBasicBlock *NewBB = AdjustJTTargetBlockForward(MBB, MI->getParent()); if (NewBB) - MJTI->ReplaceMBBInJumpTables(JTBBs[j], NewBB); + MJTI->ReplaceMBBInJumpTable(JTI, JTBBs[j], NewBB); MadeChange = true; } } @@ -1772,16 +1772,16 @@ int Size = BBSizes[BBI]; MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; - // If the block terminator isn't analyzable, don't try to move the block - if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond)) - return NULL; - // If the block is small and ends in an unconditional branch, move it. if (Size < 50 && Cond.empty()) { + // If the block terminator isn't analyzable, don't try to move the block + if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond)) + return NULL; + MachineFunction::iterator OldPrior = prior(BB); BB->moveAfter(JTBB); OldPrior->updateTerminator(); - //BB->updateTerminator(); + BB->updateTerminator(); ++NumJTMoved; return NULL; } @@ -1792,20 +1792,22 @@ MachineFunction::iterator MBBI = JTBB; ++MBBI; MF.insert(MBBI, NewBB); + //MF.splice(MBBI, NewBB, NewBB); + // Add an unconditional branch from NewBB to BB. // There doesn't seem to be meaningful DebugInfo available; this doesn't // correspond directly to anything in the source. assert (isThumb2 && "Adjusting for TB[BH] but not in Thumb2?"); BuildMI(NewBB, DebugLoc::getUnknownLoc(), TII->get(ARM::t2B)).addMBB(BB); + // Update internal data structures to account for the newly inserted MBB. + MF.RenumberBlocks(NewBB); + // Update the CFG. NewBB->addSuccessor(BB); JTBB->removeSuccessor(BB); JTBB->addSuccessor(NewBB); - // Update internal data structures to account for the newly inserted MBB. - MF.RenumberBlocks(); - // Insert a size into BBSizes to align it properly with the (newly // renumbered) block numbers. BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); From grosbach at apple.com Sat Nov 14 14:15:03 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 20:15:03 -0000 Subject: [llvm-commits] [llvm] r88806 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp Message-ID: <200911142015.nAEKF3To014951@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 14 14:15:03 2009 New Revision: 88806 URL: http://llvm.org/viewvc/llvm-project?rev=88806&view=rev Log: Do not merge jump tables this early. Branch folding will do any necessary merges, and until then, it's useful to keep the tables separate for ease of manipulation. Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=88806&r1=88805&r2=88806&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Nov 14 14:15:03 2009 @@ -530,10 +530,6 @@ unsigned MachineJumpTableInfo::getJumpTableIndex( const std::vector &DestBBs) { assert(!DestBBs.empty() && "Cannot create an empty jump table!"); - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) - if (JumpTables[i].MBBs == DestBBs) - return i; - JumpTables.push_back(MachineJumpTableEntry(DestBBs)); return JumpTables.size()-1; } From grosbach at apple.com Sat Nov 14 15:33:37 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 21:33:37 -0000 Subject: [llvm-commits] [llvm] r88812 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200911142133.nAELXbUX017842@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 14 15:33:37 2009 New Revision: 88812 URL: http://llvm.org/viewvc/llvm-project?rev=88812&view=rev Log: cleanup. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=88812&r1=88811&r2=88812&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Sat Nov 14 15:33:37 2009 @@ -48,7 +48,7 @@ static cl::opt -AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(false), +AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(true), cl::desc("Adjust basic block layout to better use TB[BH]")); namespace { @@ -1792,8 +1792,6 @@ MachineFunction::iterator MBBI = JTBB; ++MBBI; MF.insert(MBBI, NewBB); - //MF.splice(MBBI, NewBB, NewBB); - // Add an unconditional branch from NewBB to BB. // There doesn't seem to be meaningful DebugInfo available; this doesn't // correspond directly to anything in the source. From daniel at zuster.org Sat Nov 14 15:36:07 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 21:36:07 -0000 Subject: [llvm-commits] [llvm] r88813 - /llvm/trunk/lib/Support/CommandLine.cpp Message-ID: <200911142136.nAELa8QA018052@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 14 15:36:07 2009 New Revision: 88813 URL: http://llvm.org/viewvc/llvm-project?rev=88813&view=rev Log: Report the detected host CPU in --version. Modified: llvm/trunk/lib/Support/CommandLine.cpp Modified: llvm/trunk/lib/Support/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=88813&r1=88812&r2=88813&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Sat Nov 14 15:36:07 2009 @@ -1153,9 +1153,12 @@ #ifndef NDEBUG OS << " with assertions"; #endif + std::string CPU = sys::getHostCPUName(); + if (CPU.empty()) CPU = "(unknown)"; OS << ".\n" << " Built " << __DATE__ << " (" << __TIME__ << ").\n" << " Host: " << sys::getHostTriple() << '\n' + << " Host CPU: " << CPU << '\n' << '\n' << " Registered Targets:\n"; From daniel at zuster.org Sat Nov 14 15:36:19 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 21:36:19 -0000 Subject: [llvm-commits] [llvm] r88814 - /llvm/trunk/lib/System/Host.cpp Message-ID: <200911142136.nAELaJvK018095@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 14 15:36:19 2009 New Revision: 88814 URL: http://llvm.org/viewvc/llvm-project?rev=88814&view=rev Log: Fill out X86 table, although we are missing lots of names for things. We now properly detect my Xeon box though. Modified: llvm/trunk/lib/System/Host.cpp Modified: llvm/trunk/lib/System/Host.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Host.cpp?rev=88814&r1=88813&r2=88814&view=diff ============================================================================== --- llvm/trunk/lib/System/Host.cpp (original) +++ llvm/trunk/lib/System/Host.cpp Sat Nov 14 15:36:19 2009 @@ -124,52 +124,136 @@ GetX86CpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1); if (memcmp(text.c, "GenuineIntel", 12) == 0) { switch (Family) { - case 3: - return "i386"; - case 4: - return "i486"; - case 5: - switch (Model) { - case 4: return "pentium-mmx"; - default: return "pentium"; - } - case 6: - switch (Model) { - case 1: return "pentiumpro"; - case 3: - case 5: - case 6: return "pentium2"; - case 7: - case 8: - case 10: - case 11: return "pentium3"; - case 9: - case 13: return "pentium-m"; - case 14: return "yonah"; - case 15: - case 22: // Celeron M 540 - return "core2"; - case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE) - return "penryn"; - default: return "i686"; - } - case 15: { - switch (Model) { - case 3: - case 4: - case 6: // same as 4, but 65nm - return (Em64T) ? "nocona" : "prescott"; - case 26: - return "corei7"; - case 28: - return "atom"; - default: - return (Em64T) ? "x86-64" : "pentium4"; - } + case 3: + return "i386"; + case 4: + switch (Model) { + case 0: // Intel486TM DX processors + case 1: // Intel486TM DX processors + case 2: // Intel486 SX processors + case 3: // Intel487TM processors, IntelDX2 OverDrive?? processors, + // IntelDX2TM processors + case 4: // Intel486 SL processor + case 5: // IntelSX2TM processors + case 7: // Write-Back Enhanced IntelDX2 processors + case 8: // IntelDX4 OverDrive processors, IntelDX4TM processors + default: return "i486"; } - + case 5: + switch (Model) { + case 1: // Pentium OverDrive processor for Pentium processor (60, 66), + // Pentium?? processors (60, 66) + case 2: // Pentium OverDrive processor for Pentium processor (75, 90, + // 100, 120, 133), Pentium processors (75, 90, 100, 120, 133, + // 150, 166, 200) + case 3: // Pentium OverDrive processors for Intel486 processor-based + // systems + return "pentium"; + + case 4: // Pentium OverDrive processor with MMXTM technology for Pentium + // processor (75, 90, 100, 120, 133), Pentium processor with + // MMXTM technology (166, 200) + return "pentium-mmx"; + + default: return "pentium"; + } + case 6: + switch (Model) { + case 1: // Pentium Pro processor + return "pentiumpro"; + + case 3: // Intel Pentium II OverDrive processor, Pentium II processor, + // model 03 + case 5: // Pentium II processor, model 05, Pentium II Xeon processor, + // model 05, and Intel?? Celeron?? processor, model 05 + case 6: // Celeron processor, model 06 + return "pentium2"; + + case 7: // Pentium III processor, model 07, and Pentium III Xeon + // processor, model 07 + case 8: // Pentium III processor, model 08, Pentium III Xeon processor, + // model 08, and Celeron processor, model 08 + case 10: // Pentium III Xeon processor, model 0Ah + case 11: // Pentium III processor, model 0Bh + return "pentium3"; + + case 9: // Intel Pentium M processor, Intel Celeron M processor model 09. + case 13: // Intel Pentium M processor, Intel Celeron M processor, model + // 0Dh. All processors are manufactured using the 90 nm process. + return "pentium-m"; + + case 14: // Intel CoreTM Duo processor, Intel CoreTM Solo processor, model + // 0Eh. All processors are manufactured using the 65 nm process. + return "yonah"; + + case 15: // Intel CoreTM2 Duo processor, Intel CoreTM2 Duo mobile + // processor, Intel CoreTM2 Quad processor, Intel CoreTM2 Quad + // mobile processor, Intel CoreTM2 Extreme processor, Intel + // Pentium Dual-Core processor, Intel Xeon processor, model + // 0Fh. All processors are manufactured using the 65 nm process. + case 22: // Intel Celeron processor model 16h. All processors are + // manufactured using the 65 nm process + return "core2"; + + case 21: // Intel EP80579 Integrated Processor and Intel EP80579 + // Integrated Processor with Intel QuickAssist Technology + return "i686"; // FIXME: ??? + + case 23: // Intel CoreTM2 Extreme processor, Intel Xeon processor, model + // 17h. All processors are manufactured using the 45 nm process. + // + // 45nm: Penryn , Wolfdale, Yorkfield (XE) + return "penryn"; + + case 26: // Intel Core i7 processor and Intel Xeon processor. All + // processors are manufactured using the 45 nm process. + case 29: // Intel Xeon processor MP. All processors are manufactured using + // the 45 nm process. + return "corei7"; + + case 28: // Intel Atom processor. All processors are manufactured using + // the 45 nm process + return "atom"; + + default: return "i686"; + } + case 15: { + switch (Model) { + case 0: // Pentium 4 processor, Intel Xeon processor. All processors are + // model 00h and manufactured using the 0.18 micron process. + case 1: // Pentium 4 processor, Intel Xeon processor, Intel Xeon + // processor MP, and Intel Celeron processor. All processors are + // model 01h and manufactured using the 0.18 micron process. + case 2: // Pentium 4 processor, Mobile Intel Pentium 4 processor ??? M, + // Intel Xeon processor, Intel Xeon processor MP, Intel Celeron + // processor, and Mobile Intel Celeron processor. All processors + // are model 02h and manufactured using the 0.13 micron process. + return (Em64T) ? "x86-64" : "pentium4"; + + case 3: // Pentium 4 processor, Intel Xeon processor, Intel Celeron D + // processor. All processors are model 03h and manufactured using + // the 90 nm process. + case 4: // Pentium 4 processor, Pentium 4 processor Extreme Edition, + // Pentium D processor, Intel Xeon processor, Intel Xeon + // processor MP, Intel Celeron D processor. All processors are + // model 04h and manufactured using the 90 nm process. + case 6: // Pentium 4 processor, Pentium D processor, Pentium processor + // Extreme Edition, Intel Xeon processor, Intel Xeon processor + // MP, Intel Celeron D processor. All processors are model 06h + // and manufactured using the 65 nm process. + return (Em64T) ? "nocona" : "prescott"; + + // FIXME: Are these bogus? + case 26: return "corei7"; + case 28: return "atom"; + + default: + return (Em64T) ? "x86-64" : "pentium4"; + } + } + default: - return "generic"; + return ""; } } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) { // FIXME: this poorly matches the generated SubtargetFeatureKV table. There @@ -209,12 +293,10 @@ case 16: return "amdfam10"; default: - return "generic"; + return ""; } - } else { - return "generic"; } -#else - return "generic"; #endif + + return ""; } From grosbach at apple.com Sat Nov 14 15:57:36 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 21:57:36 -0000 Subject: [llvm-commits] [llvm] r88817 - /llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Message-ID: <200911142157.nAELvacU019305@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 14 15:57:35 2009 New Revision: 88817 URL: http://llvm.org/viewvc/llvm-project?rev=88817&view=rev Log: remove xfail Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll?rev=88817&r1=88816&r2=88817&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-tbh.ll Sat Nov 14 15:57:35 2009 @@ -2,8 +2,6 @@ ; Thumb2 target should reorder the bb's in order to use tbb / tbh. -; XFAIL: * - %struct.R_flstr = type { i32, i32, i8* } %struct._T_tstr = type { i32, %struct.R_flstr*, %struct._T_tstr* } @_C_nextcmd = external global i32 ; [#uses=3] From daniel at zuster.org Sat Nov 14 16:04:43 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 14 Nov 2009 22:04:43 -0000 Subject: [llvm-commits] [llvm] r88818 - /llvm/trunk/lib/System/Host.cpp Message-ID: <200911142204.nAEM4hFE019505@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 14 16:04:42 2009 New Revision: 88818 URL: http://llvm.org/viewvc/llvm-project?rev=88818&view=rev Log: Remove bogus corei7 and atom entries, the family was incorrect. Modified: llvm/trunk/lib/System/Host.cpp Modified: llvm/trunk/lib/System/Host.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Host.cpp?rev=88818&r1=88817&r2=88818&view=diff ============================================================================== --- llvm/trunk/lib/System/Host.cpp (original) +++ llvm/trunk/lib/System/Host.cpp Sat Nov 14 16:04:42 2009 @@ -243,10 +243,6 @@ // and manufactured using the 65 nm process. return (Em64T) ? "nocona" : "prescott"; - // FIXME: Are these bogus? - case 26: return "corei7"; - case 28: return "atom"; - default: return (Em64T) ? "x86-64" : "pentium4"; } From evan.cheng at apple.com Sat Nov 14 16:14:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 14 Nov 2009 14:14:37 -0800 Subject: [llvm-commits] [llvm] r88806 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp In-Reply-To: <200911142015.nAEKF3To014951@zion.cs.uiuc.edu> References: <200911142015.nAEKF3To014951@zion.cs.uiuc.edu> Message-ID: Jim, I'd prefer to disable the sharing only when it's known to be unsafe. Is that possible? Evan On Nov 14, 2009, at 12:15 PM, Jim Grosbach wrote: > Author: grosbach > Date: Sat Nov 14 14:15:03 2009 > New Revision: 88806 > > URL: http://llvm.org/viewvc/llvm-project?rev=88806&view=rev > Log: > Do not merge jump tables this early. Branch folding will do any > necessary > merges, and until then, it's useful to keep the tables separate for > ease > of manipulation. > > Modified: > llvm/trunk/lib/CodeGen/MachineFunction.cpp > > Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=88806&r1=88805&r2=88806&view=diff > > === > === > === > ===================================================================== > --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Nov 14 14:15:03 > 2009 > @@ -530,10 +530,6 @@ > unsigned MachineJumpTableInfo::getJumpTableIndex( > const std::vector > &DestBBs) { > assert(!DestBBs.empty() && "Cannot create an empty jump table!"); > - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) > - if (JumpTables[i].MBBs == DestBBs) > - return i; > - > JumpTables.push_back(MachineJumpTableEntry(DestBBs)); > return JumpTables.size()-1; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Sat Nov 14 16:27:25 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Nov 2009 14:27:25 -0800 Subject: [llvm-commits] [llvm] r88806 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp In-Reply-To: References: <200911142015.nAEKF3To014951@zion.cs.uiuc.edu> Message-ID: <9AC7768F-399C-444D-B1B9-105706ED9541@apple.com> On Nov 14, 2009, at 2:14 PM, Evan Cheng wrote: > Jim, I'd prefer to disable the sharing only when it's known to be > unsafe. Is that possible? > I don't see a straightforward way to identify when it's appropriate and when it's not at this point. The more I look at it, the more I feel doing the merging here is pre-mature, and if it's useful, it should be done significantly later in the compilation, after any optimizations that may manipulate the tables in other ways have run. If we're sharing tables, when we're manipulating the destinations of one jump table branch, we're also potentially changing the destination blocks for other branches which use the same table. That'll cause the CFG to be incorrect for those branches, and things go very badly from there. That said, if anyone has suggestions for alternative approaches that clean up the above problem while still allowing us to share the tables this early, that'd be great. -Jim > On Nov 14, 2009, at 12:15 PM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Sat Nov 14 14:15:03 2009 >> New Revision: 88806 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=88806&view=rev >> Log: >> Do not merge jump tables this early. Branch folding will do any >> necessary >> merges, and until then, it's useful to keep the tables separate for >> ease >> of manipulation. >> >> Modified: >> llvm/trunk/lib/CodeGen/MachineFunction.cpp >> >> Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=88806&r1=88805&r2=88806&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) >> +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Nov 14 14:15:03 >> 2009 >> @@ -530,10 +530,6 @@ >> unsigned MachineJumpTableInfo::getJumpTableIndex( >> const std::vector >> &DestBBs) { >> assert(!DestBBs.empty() && "Cannot create an empty jump table!"); >> - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) >> - if (JumpTables[i].MBBs == DestBBs) >> - return i; >> - >> JumpTables.push_back(MachineJumpTableEntry(DestBBs)); >> return JumpTables.size()-1; >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Sat Nov 14 19:02:09 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sun, 15 Nov 2009 01:02:09 -0000 Subject: [llvm-commits] [llvm] r88827 - in /llvm/trunk: docs/CommandGuide/lit.pod utils/lit/Test.py utils/lit/TestRunner.py utils/lit/lit.py Message-ID: <200911150102.nAF12AJH024876@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 14 19:02:09 2009 New Revision: 88827 URL: http://llvm.org/viewvc/llvm-project?rev=88827&view=rev Log: lit: Add --repeat=N option, for running each test N times. - Currently just useful for timing, although it could be extended as one (bad) way to deal with flaky tests. Modified: llvm/trunk/docs/CommandGuide/lit.pod llvm/trunk/utils/lit/Test.py llvm/trunk/utils/lit/TestRunner.py llvm/trunk/utils/lit/lit.py Modified: llvm/trunk/docs/CommandGuide/lit.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lit.pod?rev=88827&r1=88826&r2=88827&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/lit.pod (original) +++ llvm/trunk/docs/CommandGuide/lit.pod Sat Nov 14 19:02:09 2009 @@ -149,6 +149,11 @@ Run Tcl scripts internally (instead of converting to shell scripts). +=item B<--repeat>=I + +Run each test I times. Currently this is primarily useful for timing tests, +other results are not collated in any reasonable fashion. + =back =head1 EXIT STATUS Modified: llvm/trunk/utils/lit/Test.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/Test.py?rev=88827&r1=88826&r2=88827&view=diff ============================================================================== --- llvm/trunk/utils/lit/Test.py (original) +++ llvm/trunk/utils/lit/Test.py Sat Nov 14 19:02:09 2009 @@ -54,6 +54,14 @@ self.output = None # The wall time to execute this test, if timing and once complete. self.elapsed = None + # The repeat index of this test, or None. + self.index = None + + def copyWithIndex(self, index): + import copy + res = copy.copy(self) + res.index = index + return res def setResult(self, result, output, elapsed): assert self.result is None, "Test result already set!" Modified: llvm/trunk/utils/lit/TestRunner.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestRunner.py?rev=88827&r1=88826&r2=88827&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestRunner.py (original) +++ llvm/trunk/utils/lit/TestRunner.py Sat Nov 14 19:02:09 2009 @@ -367,6 +367,8 @@ execpath = test.getExecPath() execdir,execbase = os.path.split(execpath) tmpBase = os.path.join(execdir, 'Output', execbase) + if test.index is not None: + tmpBase += '_%d' % test.index # We use #_MARKER_# to hide %% while we do the other substitutions. substitutions = [('%%', '#_MARKER_#')] Modified: llvm/trunk/utils/lit/lit.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit.py?rev=88827&r1=88826&r2=88827&view=diff ============================================================================== --- llvm/trunk/utils/lit/lit.py (original) +++ llvm/trunk/utils/lit/lit.py Sat Nov 14 19:02:09 2009 @@ -388,6 +388,9 @@ group.add_option("", "--no-tcl-as-sh", dest="useTclAsSh", help="Don't run Tcl scripts using 'sh'", action="store_false", default=True) + group.add_option("", "--repeat", dest="repeatTests", metavar="N", + help="Repeat tests N times (for timing)", + action="store", default=None, type=int) parser.add_option_group(group) (opts, args) = parser.parse_args() @@ -472,6 +475,11 @@ header = '-- Testing: %d%s tests, %d threads --'%(len(tests),extra, opts.numThreads) + if opts.repeatTests: + tests = [t.copyWithIndex(i) + for t in tests + for i in range(opts.repeatTests)] + progressBar = None if not opts.quiet: if opts.succinct and opts.useProgressBar: @@ -524,11 +532,16 @@ print if opts.timeTests: - byTime = list(tests) - byTime.sort(key = lambda t: t.elapsed) + # Collate, in case we repeated tests. + times = {} + for t in tests: + key = t.getFullName() + times[key] = times.get(key, 0.) + t.elapsed + + byTime = list(times.items()) + byTime.sort(key = lambda (name,elapsed): elapsed) if byTime: - Util.printHistogram([(t.getFullName(), t.elapsed) for t in byTime], - title='Tests') + Util.printHistogram(byTime, title='Tests') for name,code in (('Expected Passes ', Test.PASS), ('Expected Failures ', Test.XFAIL), From espindola at google.com Sat Nov 14 21:21:47 2009 From: espindola at google.com (Rafael Espindola) Date: Sat, 14 Nov 2009 22:21:47 -0500 Subject: [llvm-commits] [PATCH] LTO code generator options In-Reply-To: <6AE1604EE3EC5F4296C096518C6B77EEFD4607BA@mail.accesssoftek.com> References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <9C7CA4093A8F41D7AD156ED3CF854D17@andreic6e7fe55> <38a0d8450911101625s5e3b7cb0m31ec0ce4d4144dc@mail.gmail.com> <38a0d8450911121059n6a0d3eb0ka34711d931c7675e@mail.gmail.com> <6AE1604EE3EC5F4296C096518C6B77EEFD4607BA@mail.accesssoftek.com> Message-ID: <38a0d8450911141921r7deec8b3k91e06950263f0485@mail.gmail.com> 2009/11/12 Viktor Kutuzov : > Thanks, Rafael. > > I have split this patch to a set of smaller ones. Hope this will make it easier to review. > Please find attached 2 patches: > > * one adds to the Triple class > ? - a new getAssemblerArchName method, and > ? - assignment operators for the std::string and StringRef types; > > * the other one adds to the SubtargetFeature class > ? - a new getDefaultSubTargetTripleFeatures method (code moved from the LTOModule class), > ? - AddFeatures methods, and > ? - hasFeature method. > > I'll send the patch that use these changes after these 2 patches will be submitted. I actually find it easier to review code when it is next to its use. Examples *) I am not sure that including a llvm::Triple = std::string is the best design. Without its use it is hard to tell. *) Looking only at getArchNameForDarwinArchTriplePart it is hard to check that it covers all cases. The attached patch was extracted from your previous one. It includes only the -arch option refactoring bits. I find it easier to read. For example, I now noticed that you forgot to handle ppc64 :-) I also adjusted it a bit for the coding style: *) Try not to nest too much, so return null early if vendor != apple *) Don't include an else after a return Would you mind completing just this part first? > Viktor. Thanks, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: arch.patch Type: text/x-diff Size: 4745 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091114/45469ee8/attachment.bin From lhames at gmail.com Sat Nov 14 22:39:56 2009 From: lhames at gmail.com (Lang Hames) Date: Sun, 15 Nov 2009 04:39:56 -0000 Subject: [llvm-commits] [llvm] r88829 - /llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Message-ID: <200911150439.nAF4duji031613@zion.cs.uiuc.edu> Author: lhames Date: Sat Nov 14 22:39:51 2009 New Revision: 88829 URL: http://llvm.org/viewvc/llvm-project?rev=88829&view=rev Log: Added an assert to the PBQP allocator to catch infinite cost solutions which might otherwise lead to miscompilations. Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=88829&r1=88828&r2=88829&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Sat Nov 14 22:39:51 2009 @@ -693,6 +693,11 @@ } bool PBQPRegAlloc::mapPBQPToRegAlloc(const PBQP::Solution &solution) { + + // Assert that this is a valid solution to the regalloc problem. + assert(solution.getCost() != std::numeric_limits::infinity() && + "Invalid (infinite cost) solution for PBQP problem."); + // Set to true if we have any spills bool anotherRoundNeeded = false; From nicholas at mxc.ca Sat Nov 14 23:55:17 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 05:55:17 -0000 Subject: [llvm-commits] [llvm] r88830 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll Message-ID: <200911150555.nAF5tI8V001330@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 14 23:55:17 2009 New Revision: 88830 URL: http://llvm.org/viewvc/llvm-project?rev=88830&view=rev Log: Teach instcombine to look for booleans in wider integers when it encounters a zext(icmp). It may be able to optimize that away. This fixes one of the cases in PR5438. Added: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=88830&r1=88829&r2=88830&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Nov 14 23:55:17 2009 @@ -8539,6 +8539,34 @@ } } + // icmp ne A, B is equal to xor A, B when A and B only really have one bit. + // It is also profitable to transform icmp eq into not(xor(A, B)) because that + // may lead to additional simplifications. + if (CI.getType() == ICI->getOperand(0)->getType()) { + if (const IntegerType *ITy = dyn_cast(CI.getType())) { + Value *LHS = ICI->getOperand(0); + Value *RHS = ICI->getOperand(1); + + uint32_t BitWidth = ITy->getBitWidth(); + APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); + APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); + APInt TypeMask(APInt::getAllOnesValue(BitWidth)); + ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); + ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); + + if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && + KnownZeroRHS.countLeadingOnes() == BitWidth-1) { + if (!DoXform) return ICI; + + Value *Xor = Builder->CreateXor(LHS, RHS); + if (ICI->isTrueWhenEqual()) + Xor = Builder->CreateXor(Xor, ConstantInt::get(ITy, 1)); + Xor->takeName(ICI); + return ReplaceInstUsesWith(CI, Xor); + } + } + } + return 0; } Added: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/compare-signs.ll?rev=88830&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/compare-signs.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Sat Nov 14 23:55:17 2009 @@ -0,0 +1,28 @@ +; RUN: opt %S -instcombine -S | FileCheck %S +; PR5438 + +; TODO: This should also optimize down. +;define i32 @bar(i32 %a, i32 %b) nounwind readnone { +;entry: +; %0 = icmp sgt i32 %a, -1 ; [#uses=1] +; %1 = icmp slt i32 %b, 0 ; [#uses=1] +; %2 = xor i1 %1, %0 ; [#uses=1] +; %3 = zext i1 %2 to i32 ; [#uses=1] +; ret i32 %3 +;} + +define i32 @qaz(i32 %a, i32 %b) nounwind readnone { +; CHECK: @qaz +entry: +; CHECK: xor i32 %a, %b +; CHECK; lshr i32 %0, 31 +; CHECK: xor i32 %1, 1 + %0 = lshr i32 %a, 31 ; [#uses=1] + %1 = lshr i32 %b, 31 ; [#uses=1] + %2 = icmp eq i32 %0, %1 ; [#uses=1] + %3 = zext i1 %2 to i32 ; [#uses=1] + ret i32 %3 +; CHECK-NOT: icmp +; CHECK-NOT: zext +; CHECK: ret i32 %2 +} From nicholas at mxc.ca Sun Nov 15 00:16:57 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 06:16:57 -0000 Subject: [llvm-commits] [llvm] r88831 - /llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Message-ID: <200911150616.nAF6Gvsx001980@zion.cs.uiuc.edu> Author: nicholas Date: Sun Nov 15 00:16:57 2009 New Revision: 88831 URL: http://llvm.org/viewvc/llvm-project?rev=88831&view=rev Log: Correct typo. Modified: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Modified: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/compare-signs.ll?rev=88831&r1=88830&r2=88831&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/compare-signs.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Sun Nov 15 00:16:57 2009 @@ -1,4 +1,4 @@ -; RUN: opt %S -instcombine -S | FileCheck %S +; RUN: opt %s -instcombine -S | FileCheck %s ; PR5438 ; TODO: This should also optimize down. From daniel at zuster.org Sun Nov 15 01:22:58 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sun, 15 Nov 2009 07:22:58 -0000 Subject: [llvm-commits] [llvm] r88838 - /llvm/trunk/utils/lit/TestFormats.py Message-ID: <200911150722.nAF7Mxu8003920@zion.cs.uiuc.edu> Author: ddunbar Date: Sun Nov 15 01:22:58 2009 New Revision: 88838 URL: http://llvm.org/viewvc/llvm-project?rev=88838&view=rev Log: Remove duplicate implementation of excludes functionality, and support excluding dirnames. Also, add support for the 'unsupported' config property. Modified: llvm/trunk/utils/lit/TestFormats.py Modified: llvm/trunk/utils/lit/TestFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestFormats.py?rev=88838&r1=88837&r2=88838&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestFormats.py (original) +++ llvm/trunk/utils/lit/TestFormats.py Sun Nov 15 01:22:58 2009 @@ -101,13 +101,12 @@ # FIXME: Refactor into generic test for running some command on a directory # of inputs. - def __init__(self, compiler, dir, recursive, pattern, excludes=[], + def __init__(self, compiler, dir, recursive, pattern, extra_cxx_args=[]): self.compiler = str(compiler) self.dir = str(dir) self.recursive = bool(recursive) self.pattern = re.compile(pattern) - self.excludes = list(excludes) self.extra_cxx_args = list(extra_cxx_args) def getTestsInDirectory(self, testSuite, path_in_suite, @@ -116,23 +115,13 @@ if not self.recursive: subdirs[:] = [] - if dirname.__contains__('.svn'): + if dirname == '.svn' or dirname in localConfig.excludes: continue - + for filename in filenames: if (not self.pattern.match(filename) or filename in localConfig.excludes): continue - - # Skip any files that were specifically excluded. - excluded = False - for exclude in self.excludes: - if filename.__contains__(exclude): - excluded = True - break - - if excluded: - continue path = os.path.join(dirname,filename) suffix = path[len(self.dir):] @@ -146,6 +135,9 @@ yield test def execute(self, test, litConfig): + if test.config.unsupported: + return (Test.UNSUPPORTED, 'Test is unsupported') + tmp = tempfile.NamedTemporaryFile(suffix='.cpp') print >>tmp, '#include "%s"' % test.source_path tmp.flush() From nicholas at mxc.ca Sun Nov 15 01:47:32 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 07:47:32 -0000 Subject: [llvm-commits] [llvm] r88841 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll Message-ID: <200911150747.nAF7lX1c004722@zion.cs.uiuc.edu> Author: nicholas Date: Sun Nov 15 01:47:32 2009 New Revision: 88841 URL: http://llvm.org/viewvc/llvm-project?rev=88841&view=rev Log: Revert r88830 and r88831 which appear to have caused a selfhost buildbot some grief. I suspect this patch merely exposed a bug else. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=88841&r1=88840&r2=88841&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Nov 15 01:47:32 2009 @@ -8539,34 +8539,6 @@ } } - // icmp ne A, B is equal to xor A, B when A and B only really have one bit. - // It is also profitable to transform icmp eq into not(xor(A, B)) because that - // may lead to additional simplifications. - if (CI.getType() == ICI->getOperand(0)->getType()) { - if (const IntegerType *ITy = dyn_cast(CI.getType())) { - Value *LHS = ICI->getOperand(0); - Value *RHS = ICI->getOperand(1); - - uint32_t BitWidth = ITy->getBitWidth(); - APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); - APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); - APInt TypeMask(APInt::getAllOnesValue(BitWidth)); - ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); - ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); - - if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && - KnownZeroRHS.countLeadingOnes() == BitWidth-1) { - if (!DoXform) return ICI; - - Value *Xor = Builder->CreateXor(LHS, RHS); - if (ICI->isTrueWhenEqual()) - Xor = Builder->CreateXor(Xor, ConstantInt::get(ITy, 1)); - Xor->takeName(ICI); - return ReplaceInstUsesWith(CI, Xor); - } - } - } - return 0; } Modified: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/compare-signs.ll?rev=88841&r1=88840&r2=88841&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/compare-signs.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Sun Nov 15 01:47:32 2009 @@ -1,4 +1,5 @@ ; RUN: opt %s -instcombine -S | FileCheck %s +; XFAIL: * ; PR5438 ; TODO: This should also optimize down. From daniel at zuster.org Sun Nov 15 02:10:29 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sun, 15 Nov 2009 08:10:29 -0000 Subject: [llvm-commits] [llvm] r88844 - in /llvm/trunk/utils/lit: LitFormats.py TestFormats.py Message-ID: <200911150810.nAF8ATt6005514@zion.cs.uiuc.edu> Author: ddunbar Date: Sun Nov 15 02:10:29 2009 New Revision: 88844 URL: http://llvm.org/viewvc/llvm-project?rev=88844&view=rev Log: lit: Factor a new OneCommandPerFileTest out of SyntaxCheckTest. - Used for running a single fixed command on a directory of files, with the option of deriving a temporary input file from the test source. Modified: llvm/trunk/utils/lit/LitFormats.py llvm/trunk/utils/lit/TestFormats.py Modified: llvm/trunk/utils/lit/LitFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/LitFormats.py?rev=88844&r1=88843&r2=88844&view=diff ============================================================================== --- llvm/trunk/utils/lit/LitFormats.py (original) +++ llvm/trunk/utils/lit/LitFormats.py Sun Nov 15 02:10:29 2009 @@ -1,2 +1,3 @@ -from TestFormats import GoogleTest, ShTest, TclTest, SyntaxCheckTest +from TestFormats import GoogleTest, ShTest, TclTest +from TestFormats import SyntaxCheckTest, OneCommandPerFileTest Modified: llvm/trunk/utils/lit/TestFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestFormats.py?rev=88844&r1=88843&r2=88844&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestFormats.py (original) +++ llvm/trunk/utils/lit/TestFormats.py Sun Nov 15 02:10:29 2009 @@ -97,17 +97,20 @@ import re import tempfile -class SyntaxCheckTest: +class OneCommandPerFileTest: # FIXME: Refactor into generic test for running some command on a directory # of inputs. - def __init__(self, compiler, dir, recursive, pattern, - extra_cxx_args=[]): - self.compiler = str(compiler) + def __init__(self, command, dir, recursive=False, + pattern=".*", useTempInput=False): + if isinstance(command, str): + self.command = [command] + else: + self.command = list(command) self.dir = str(dir) self.recursive = bool(recursive) self.pattern = re.compile(pattern) - self.extra_cxx_args = list(extra_cxx_args) + self.useTempInput = useTempInput def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, localConfig): @@ -134,20 +137,46 @@ test.source_path = path yield test + def createTempInput(self, tmp, test): + abstract + def execute(self, test, litConfig): if test.config.unsupported: return (Test.UNSUPPORTED, 'Test is unsupported') - tmp = tempfile.NamedTemporaryFile(suffix='.cpp') - print >>tmp, '#include "%s"' % test.source_path - tmp.flush() + cmd = list(self.command) + + # If using temp input, create a temporary file and hand it to the + # subclass. + if self.useTempInput: + tmp = tempfile.NamedTemporaryFile(suffix='.cpp') + self.createTempInput(tmp, test) + tmp.flush() + cmd.append(tmp.name) + else: + cmd.append(test.source_path) - cmd = [self.compiler, '-x', 'c++', '-fsyntax-only', tmp.name] - cmd.extend(self.extra_cxx_args) out, err, exitCode = TestRunner.executeCommand(cmd) diags = out + err if not exitCode and not diags.strip(): return Test.PASS,'' - return Test.FAIL, diags + # Try to include some useful information. + report = """Command: %s\n""" % ' '.join(["'%s'" % a + for a in cmd]) + if self.useTempInput: + report += """Temporary File: %s\n""" % tmp.name + report += "--\n%s--\n""" % open(tmp.name).read() + report += """Output:\n--\n%s--""" % diags + + return Test.FAIL, report + +class SyntaxCheckTest(OneCommandPerFileTest): + def __init__(self, compiler, dir, extra_cxx_args=[], *args, **kwargs): + cmd = [compiler, '-x', 'c++', '-fsyntax-only'] + extra_cxx_args + OneCommandPerFileTest.__init__(self, cmd, dir, + useTempInput=1, *args, **kwargs) + + def createTempInput(self, tmp, test): + print >>tmp, '#include "%s"' % test.source_path From baldrick at free.fr Sun Nov 15 03:13:26 2009 From: baldrick at free.fr (Duncan Sands) Date: Sun, 15 Nov 2009 10:13:26 +0100 Subject: [llvm-commits] [llvm] r88830 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll In-Reply-To: <200911150555.nAF5tI8V001330@zion.cs.uiuc.edu> References: <200911150555.nAF5tI8V001330@zion.cs.uiuc.edu> Message-ID: <4AFFC636.8000801@free.fr> Hi Nick, > + if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && > + KnownZeroRHS.countLeadingOnes() == BitWidth-1) { don't you want >= here, in case the value is known to be zero? Ciao, Duncan. From resistor at mac.com Sun Nov 15 03:35:45 2009 From: resistor at mac.com (Owen Anderson) Date: Sun, 15 Nov 2009 01:35:45 -0800 Subject: [llvm-commits] [llvm] r88806 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp In-Reply-To: <9AC7768F-399C-444D-B1B9-105706ED9541@apple.com> References: <200911142015.nAEKF3To014951@zion.cs.uiuc.edu> <9AC7768F-399C-444D-B1B9-105706ED9541@apple.com> Message-ID: <43E70790-5702-4777-8561-B41C360988F4@mac.com> On Nov 14, 2009, at 2:27 PM, Jim Grosbach wrote: > If we're sharing tables, when we're manipulating the destinations of > one jump table branch, we're also potentially changing the destination > blocks for other branches which use the same table. That'll cause the > CFG to be incorrect for those branches, and things go very badly from > there. FWIW, this was a major problem with implementing StrongPHIElimination. It assumes that all critical edges can be split, and being unable to hack on jump tables severely complicated that. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091115/46209112/attachment.bin From eocallaghan at auroraux.org Sun Nov 15 04:18:18 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Sun, 15 Nov 2009 10:18:18 -0000 Subject: [llvm-commits] [llvm] r88849 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp Message-ID: <200911151018.nAFAIIDo024201@zion.cs.uiuc.edu> Author: evocallaghan Date: Sun Nov 15 04:18:17 2009 New Revision: 88849 URL: http://llvm.org/viewvc/llvm-project?rev=88849&view=rev Log: Add PSP OS Target to Triple, Credit to Bruno Cardoso Lopes. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=88849&r1=88848&r2=88849&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Sun Nov 15 04:18:17 2009 @@ -94,6 +94,7 @@ MinGW64, NetBSD, OpenBSD, + Psp, Solaris, Win32, Haiku Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=88849&r1=88848&r2=88849&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Sun Nov 15 04:18:17 2009 @@ -94,6 +94,7 @@ case MinGW64: return "mingw64"; case NetBSD: return "netbsd"; case OpenBSD: return "openbsd"; + case Psp: return "psp"; case Solaris: return "solaris"; case Win32: return "win32"; case Haiku: return "haiku"; @@ -273,6 +274,8 @@ OS = NetBSD; else if (OSName.startswith("openbsd")) OS = OpenBSD; + else if (OSName.startswith("psp")) + OS = Psp; else if (OSName.startswith("solaris")) OS = Solaris; else if (OSName.startswith("win32")) From gohman at apple.com Sun Nov 15 09:35:35 2009 From: gohman at apple.com (Dan Gohman) Date: Sun, 15 Nov 2009 07:35:35 -0800 Subject: [llvm-commits] [PATCH] Make X86-64 in the Large model always emit 64-bit calls In-Reply-To: References: <001636ed6e725660440478316be4@google.com> <77E51FA6-221B-413B-8F7E-1DFDF49168A2@apple.com> Message-ID: <7EF5C717-F5FA-4353-A6CD-84302167F04E@apple.com> On Nov 12, 2009, at 2:35 PM, Jeffrey Yasskin wrote: > On Thu, Nov 12, 2009 at 11:46 AM, Dan Gohman wrote: >> In the X86ISelLowering.cpp part, disabling the special handling >> for GlobalAddresses and ExternalSymbols is fine, but the way the >> proposed patch does that also happens to disable the >> "else if (isTailCall)" code immediately below that, which handles >> indirect tail calls. That code is still needed in the large code >> model -- the callee needs to be in a specific physical register >> so that it can survive the epilogue. > > Oh, right. New version of the patch at > http://codereview.appspot.com/154066 / > http://codereview.appspot.com/download/issue154066_23.diff The X86ISelLowering change looks good. Dan From nicholas at mxc.ca Sun Nov 15 11:09:25 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 09:09:25 -0800 Subject: [llvm-commits] [test-suite] r86296 - /test-suite/trunk/SingleSource/Regression/C/packssdw-1.c In-Reply-To: <200911062255.nA6Mt2uU007996@zion.cs.uiuc.edu> References: <200911062255.nA6Mt2uU007996@zion.cs.uiuc.edu> Message-ID: <4B0035C5.7090801@mxc.ca> Eric Christopher wrote: > Author: echristo > Date: Fri Nov 6 16:55:01 2009 > New Revision: 86296 > > URL: http://llvm.org/viewvc/llvm-project?rev=86296&view=rev > Log: > Add a very primitive test for packssdw builtins. This breaks my nightly build: $ gcc packssdw-1.c In file included from packssdw-1.c:1: /usr/lib/gcc/i486-linux-gnu/4.3.4/include/emmintrin.h:34:3: error: #error "SSE2 instruction set not enabled" packssdw-1.c:4: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?foo? packssdw-1.c: In function ?main?: packssdw-1.c:11: error: ?__v4si? undeclared (first use in this function) packssdw-1.c:11: error: (Each undeclared identifier is reported only once packssdw-1.c:11: error: for each function it appears in.) packssdw-1.c:11: error: expected ?;? before ?a? packssdw-1.c:12: error: expected ?;? before ?b? packssdw-1.c:14: error: ?__v16qi? undeclared (first use in this function) packssdw-1.c:14: error: expected ?;? before ?c? packssdw-1.c:16: error: expected ?)? before ?c? $ gcc packssdw-1.c -msse2 packssdw-1.c: In function ?foo?: packssdw-1.c:6: note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts packssdw-1.c:6: error: incompatible types in return $ Nick > Added: > test-suite/trunk/SingleSource/Regression/C/packssdw-1.c > > Added: test-suite/trunk/SingleSource/Regression/C/packssdw-1.c > URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/packssdw-1.c?rev=86296&view=auto > > ============================================================================== > --- test-suite/trunk/SingleSource/Regression/C/packssdw-1.c (added) > +++ test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Fri Nov 6 16:55:01 2009 > @@ -0,0 +1,22 @@ > +#include > +#include > + > +__v16qi foo (__v4si a, __v4si b) > +{ > + return __builtin_ia32_packssdw128(a, b); > +} > + > +int main (void) > +{ > + __v4si a = { 0, 0, 0, 0}; > + __v4si b = { 0, 0, 0, 0}; > + > + __v16qi c = foo(a, b); > + > + if (__builtin_ia32_vec_ext_v4si((__v4si)c, 0) == 0) > + printf("packssdw-1 passed\n"); > + else > + printf("packssdw-1 failed\n"); > + > + return 0; > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From nicholas at mxc.ca Sun Nov 15 11:10:33 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 17:10:33 -0000 Subject: [llvm-commits] [test-suite] r88853 - /test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Message-ID: <200911151710.nAFHAXYb025889@zion.cs.uiuc.edu> Author: nicholas Date: Sun Nov 15 11:10:33 2009 New Revision: 88853 URL: http://llvm.org/viewvc/llvm-project?rev=88853&view=rev Log: Revert r86296. This program doesn't even build with gcc, and is therefore breaking nightly test runs. Removed: test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Removed: test-suite/trunk/SingleSource/Regression/C/packssdw-1.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/packssdw-1.c?rev=88852&view=auto ============================================================================== --- test-suite/trunk/SingleSource/Regression/C/packssdw-1.c (original) +++ test-suite/trunk/SingleSource/Regression/C/packssdw-1.c (removed) @@ -1,22 +0,0 @@ -#include -#include - -__v16qi foo (__v4si a, __v4si b) -{ - return __builtin_ia32_packssdw128(a, b); -} - -int main (void) -{ - __v4si a = { 0, 0, 0, 0}; - __v4si b = { 0, 0, 0, 0}; - - __v16qi c = foo(a, b); - - if (__builtin_ia32_vec_ext_v4si((__v4si)c, 0) == 0) - printf("packssdw-1 passed\n"); - else - printf("packssdw-1 failed\n"); - - return 0; -} From baldrick at free.fr Sun Nov 15 11:18:35 2009 From: baldrick at free.fr (Duncan Sands) Date: Sun, 15 Nov 2009 17:18:35 -0000 Subject: [llvm-commits] [dragonegg] r88854 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h llvm-types.cpp Message-ID: <200911151718.nAFHIZnD026168@zion.cs.uiuc.edu> Author: baldrick Date: Sun Nov 15 11:18:35 2009 New Revision: 88854 URL: http://llvm.org/viewvc/llvm-project?rev=88854&view=rev Log: Add some additional sanity checking. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h dragonegg/trunk/llvm-types.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=88854&r1=88853&r2=88854&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Sun Nov 15 11:18:35 2009 @@ -2159,8 +2159,11 @@ assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); DenseMap >::iterator I = SSANames.find(reg); - if (I != SSANames.end()) + if (I != SSANames.end()) { + assert(I->second->getType() == ConvertType(TREE_TYPE(reg)) && + "SSA name has wrong type!"); return I->second; + } // This SSA name is the default definition for the underlying symbol. assert(SSA_NAME_IS_DEFAULT_DEF(reg) && "SSA name used before being defined!"); @@ -2172,6 +2175,8 @@ // If the variable is itself an ssa name, use its LLVM value. if (TREE_CODE (var) == SSA_NAME) { Value *Val = EmitSSA_NAME(var); + assert(Val->getType() == ConvertType(TREE_TYPE(reg)) && + "SSA name has wrong type!"); return SSANames[reg] = Val; } @@ -2241,6 +2246,8 @@ if (SavedInsertBB != EntryBlock) Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); + assert(Address->getType() == ConvertType(TREE_TYPE(reg)) && + "Invariant address has wrong type!"); return Address; } @@ -2248,22 +2255,32 @@ Constant *TreeToLLVM::EmitGimpleConstant(tree reg) { assert(is_gimple_constant(reg) && "Not a gimple constant!"); assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); + + Constant *C; switch (TREE_CODE(reg)) { default: debug_tree(reg); llvm_unreachable("Unhandled GIMPLE constant!"); case INTEGER_CST: - return TreeConstantToLLVM::ConvertINTEGER_CST(reg); + C = TreeConstantToLLVM::ConvertINTEGER_CST(reg); + break; case REAL_CST: - return TreeConstantToLLVM::ConvertREAL_CST(reg); + C = TreeConstantToLLVM::ConvertREAL_CST(reg); + break; case COMPLEX_CST: - return TreeConstantToLLVM::ConvertCOMPLEX_CST(reg); + C = TreeConstantToLLVM::ConvertCOMPLEX_CST(reg); + break; case VECTOR_CST: - return TreeConstantToLLVM::ConvertVECTOR_CST(reg); + C = TreeConstantToLLVM::ConvertVECTOR_CST(reg); + break; case CONSTRUCTOR: - return TreeConstantToLLVM::ConvertCONSTRUCTOR(reg); + C = TreeConstantToLLVM::ConvertCONSTRUCTOR(reg); + break; } + assert(C->getType() == ConvertType(TREE_TYPE(reg)) && + "Constant has wrong type!"); + return C; } Value *TreeToLLVM::EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc) { Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=88854&r1=88853&r2=88854&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Sun Nov 15 11:18:35 2009 @@ -500,17 +500,21 @@ /// EmitGimpleMinInvariant - The given value is constant in this function. /// Return the corresponding LLVM value. Only creates code in the entry block. Value *EmitGimpleMinInvariant(tree_node *reg) { - if (TREE_CODE(reg) == ADDR_EXPR) - return EmitGimpleInvariantAddress(reg); - return EmitGimpleConstant(reg); + Value *V = (TREE_CODE(reg) == ADDR_EXPR) ? + EmitGimpleInvariantAddress(reg) : EmitGimpleConstant(reg); + assert(V->getType() == ConvertType(TREE_TYPE(reg)) && + "Gimple min invariant has wrong type!"); + return V; } /// EmitGimpleReg - Convert the specified gimple register or local constant of /// register type to an LLVM value. Only creates code in the entry block. Value *EmitGimpleReg(tree_node *reg) { - if (TREE_CODE(reg) == SSA_NAME) - return EmitSSA_NAME(reg); - return EmitGimpleMinInvariant(reg); + Value *V = (TREE_CODE(reg) == SSA_NAME) ? + EmitSSA_NAME(reg) : EmitGimpleMinInvariant(reg); + assert(V->getType() == ConvertType(TREE_TYPE(reg)) && + "Gimple register has wrong type!"); + return V; } /// Emit - Convert the specified tree node to LLVM code. If the node is an Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=88854&r1=88853&r2=88854&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Sun Nov 15 11:18:35 2009 @@ -69,6 +69,34 @@ const Type *llvm_set_type(tree Tr, const Type *Ty) { assert(TYPE_P(Tr) && "Expected a gcc type!"); + + // Check that the LLVM and GCC types have the same size, or, if the type has + // variable size, that the LLVM type is not bigger than any possible value of + // the GCC type. +#ifndef NDEBUG + if (TYPE_SIZE(Tr) && Ty->isSized()) { + if (isInt64(TYPE_SIZE(Tr), true)) { + // Type with constant (and not humongous) size. Sizes must be equal. + assert(getInt64(TYPE_SIZE(Tr), true) == + getTargetData().getTypeAllocSizeInBits(Ty) && + "LLVM type size doesn't match GCC type size!"); + } else { + // Type with variable or humongous size. LLVM size must be smaller or + // equal to the GCC size. + // TODO: Implement an effective check here. Size expressions can be too + // complicated for "fold" to simplify effectively; this mostly seems to be + // due to Ada's size type and bitsize types being signed (meaning that the + // folder can't always tell that values are non-negative). +//TODO tree LLVMSize = build_int_cst(TREE_TYPE(TYPE_SIZE(Tr)), +//TODO getTargetData().getTypeAllocSizeInBits(Ty)); +//TODO tree isSmaller = fold_build2(LE_EXPR, boolean_type_node, LLVMSize, +//TODO TYPE_SIZE(Tr)); +//TODO assert(integer_onep(isSmaller) && +//TODO "LLVM type may be larger than GCC type!"); + } + } +#endif + return (const Type *)llvm_set_cached(Tr, Ty); } From nicholas at mxc.ca Sun Nov 15 11:51:23 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 17:51:23 -0000 Subject: [llvm-commits] [llvm] r88855 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911151751.nAFHpNl2027288@zion.cs.uiuc.edu> Author: nicholas Date: Sun Nov 15 11:51:23 2009 New Revision: 88855 URL: http://llvm.org/viewvc/llvm-project?rev=88855&view=rev Log: Add a complex missed optimization opportunity I came across while investigating bug 5438. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=88855&r1=88854&r2=88855&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Sun Nov 15 11:51:23 2009 @@ -1719,3 +1719,18 @@ int bar() { return foo("abcd"); } //===---------------------------------------------------------------------===// + +InstCombine should use SimplifyDemandedBits to remove the or instruction: + +define i1 @test(i8 %x, i8 %y) { + %A = or i8 %x, 1 + %B = icmp ugt i8 %A, 3 + ret i1 %B +} + +Currently instcombine calls SimplifyDemandedBits with either all bits or just +the sign bit, if the comparison is obviously a sign test. In this case, we only +need all but the bottom two bits from %A, and if we gave that mask to SDB it +would delete the or instruction for us. + +//===---------------------------------------------------------------------===// From nicholas at mxc.ca Sun Nov 15 11:57:31 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Nov 2009 09:57:31 -0800 Subject: [llvm-commits] [llvm] r88830 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll In-Reply-To: <4AFFC636.8000801@free.fr> References: <200911150555.nAF5tI8V001330@zion.cs.uiuc.edu> <4AFFC636.8000801@free.fr> Message-ID: <4B00410B.3090101@mxc.ca> Duncan Sands wrote: > Hi Nick, > >> + if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && >> + KnownZeroRHS.countLeadingOnes() == BitWidth-1) { > > don't you want >= here, in case the value is known to be zero? Oh, sure. If the value is zero then I would've expected it to be optimized anyhow, but there's no harm in adding that case. Nick From bruno.cardoso at gmail.com Sun Nov 15 13:24:24 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Sun, 15 Nov 2009 19:24:24 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r88860 - in /llvm-gcc-4.2/trunk/gcc/config/mips: llvm-mips-target.h mips.h Message-ID: <200911151924.nAFJOO8u030480@zion.cs.uiuc.edu> Author: bruno Date: Sun Nov 15 13:24:23 2009 New Revision: 88860 URL: http://llvm.org/viewvc/llvm-project?rev=88860&view=rev Log: Move LLVM_TARGET_NAME for Mips out of llvm-mips-target Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h llvm-gcc-4.2/trunk/gcc/config/mips/mips.h Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h?rev=88860&r1=88859&r2=88860&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h Sun Nov 15 13:24:23 2009 @@ -27,11 +27,6 @@ #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ llvm_mips_should_pass_aggregate_in_memory(X, TY) -/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to - * the llvm::InitializeXXXTarget() function. - */ -#define LLVM_TARGET_NAME Mips - #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/config/mips/mips.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/mips.h?rev=88860&r1=88859&r2=88860&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/mips/mips.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/mips/mips.h Sun Nov 15 13:24:23 2009 @@ -27,6 +27,11 @@ #ifdef ENABLE_LLVM +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME Mips + /* Add general target specific stuff */ #include "llvm-mips-target.h" From echristo at apple.com Sun Nov 15 13:37:34 2009 From: echristo at apple.com (Eric Christopher) Date: Sun, 15 Nov 2009 11:37:34 -0800 Subject: [llvm-commits] [test-suite] r86296 - /test-suite/trunk/SingleSource/Regression/C/packssdw-1.c In-Reply-To: <4B0035C5.7090801@mxc.ca> References: <200911062255.nA6Mt2uU007996@zion.cs.uiuc.edu> <4B0035C5.7090801@mxc.ca> Message-ID: <88E7445A-6594-4DE7-B34A-1118620BB6FB@apple.com> On Nov 15, 2009, at 9:09 AM, Nick Lewycky wrote: > Eric Christopher wrote: >> Author: echristo >> Date: Fri Nov 6 16:55:01 2009 >> New Revision: 86296 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86296&view=rev >> Log: >> Add a very primitive test for packssdw builtins. > > This breaks my nightly build: > > $ gcc packssdw-1.c > In file included from packssdw-1.c:1: > /usr/lib/gcc/i486-linux-gnu/4.3.4/include/emmintrin.h:34:3: error: #error "SSE2 instruction set not enabled" > packssdw-1.c:4: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?foo? > packssdw-1.c: In function ?main?: > packssdw-1.c:11: error: ?__v4si? undeclared (first use in this function) > packssdw-1.c:11: error: (Each undeclared identifier is reported only once > packssdw-1.c:11: error: for each function it appears in.) > packssdw-1.c:11: error: expected ?;? before ?a? > packssdw-1.c:12: error: expected ?;? before ?b? > packssdw-1.c:14: error: ?__v16qi? undeclared (first use in this function) > packssdw-1.c:14: error: expected ?;? before ?c? > packssdw-1.c:16: error: expected ?)? before ?c? > $ gcc packssdw-1.c -msse2 > packssdw-1.c: In function ?foo?: > packssdw-1.c:6: note: use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts > packssdw-1.c:6: error: incompatible types in return > $ Hunh. Neat. I'll look into it. Thanks. -eric From sabre at nondot.org Sun Nov 15 13:52:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:52:44 -0000 Subject: [llvm-commits] [llvm] r88861 - /llvm/trunk/include/llvm/ADT/STLExtras.h Message-ID: <200911151952.nAFJqiuO031386@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:52:43 2009 New Revision: 88861 URL: http://llvm.org/viewvc/llvm-project?rev=88861&view=rev Log: add a version of array_pod_sort that takes a custom comparator function. Modified: llvm/trunk/include/llvm/ADT/STLExtras.h Modified: llvm/trunk/include/llvm/ADT/STLExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=88861&r1=88860&r2=88861&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/STLExtras.h (original) +++ llvm/trunk/include/llvm/ADT/STLExtras.h Sun Nov 15 13:52:43 2009 @@ -270,6 +270,14 @@ get_array_pad_sort_comparator(*Start)); } +template +static inline void array_pod_sort(IteratorTy Start, IteratorTy End, + int (*Compare)(const void*, const void*)) { + // Don't dereference start iterator of empty sequence. + if (Start == End) return; + qsort(&*Start, End-Start, sizeof(*Start), Compare); +} + } // End llvm namespace #endif From sabre at nondot.org Sun Nov 15 13:54:31 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:54:31 -0000 Subject: [llvm-commits] [llvm] r88862 - /llvm/trunk/include/llvm/Support/Compiler.h Message-ID: <200911151954.nAFJsVEc031445@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:54:31 2009 New Revision: 88862 URL: http://llvm.org/viewvc/llvm-project?rev=88862&view=rev Log: add attributes for readnone/readonly functions. Modified: llvm/trunk/include/llvm/Support/Compiler.h Modified: llvm/trunk/include/llvm/Support/Compiler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=88862&r1=88861&r2=88862&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h (original) +++ llvm/trunk/include/llvm/Support/Compiler.h Sun Nov 15 13:54:31 2009 @@ -29,6 +29,18 @@ #define ATTRIBUTE_USED #endif +#ifdef __GNUC__ // aka 'ATTRIBUTE_CONST' but following LLVM Conventions. +#define ATTRIBUTE_READNONE __attribute__((__const__)) +#else +#define ATTRIBUTE_READNONE +#endif + +#ifdef __GNUC__ // aka 'ATTRIBUTE_PURE' but following LLVM Conventions. +#define ATTRIBUTE_READONLY __attribute__((__pure__)) +#else +#define ATTRIBUTE_READONLY +#endif + #if (__GNUC__ >= 4) #define BUILTIN_EXPECT(EXPR, VALUE) __builtin_expect((EXPR), (VALUE)) #else From sabre at nondot.org Sun Nov 15 13:56:28 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:56:28 -0000 Subject: [llvm-commits] [llvm] r88863 - /llvm/trunk/include/llvm/Function.h Message-ID: <200911151956.nAFJuSvH031521@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:56:28 2009 New Revision: 88863 URL: http://llvm.org/viewvc/llvm-project?rev=88863&view=rev Log: mark getIntrinsicID() 'readonly'. This allows various classof methods (like DbgDeclareInst's) to shrink substantially. It sucks that we have to pull Compiler.h into such a public header, but at least Compiler.h doesn't pull anything else in. Modified: llvm/trunk/include/llvm/Function.h Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=88863&r1=88862&r2=88863&view=diff ============================================================================== --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Sun Nov 15 13:56:28 2009 @@ -23,6 +23,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Argument.h" #include "llvm/Attributes.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -148,7 +149,7 @@ /// The particular intrinsic functions which correspond to this value are /// defined in llvm/Intrinsics.h. /// - unsigned getIntrinsicID() const; + unsigned getIntrinsicID() const ATTRIBUTE_READONLY; bool isIntrinsic() const { return getIntrinsicID() != 0; } /// getCallingConv()/setCallingConv(CC) - These method get and set the From sabre at nondot.org Sun Nov 15 13:57:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:57:43 -0000 Subject: [llvm-commits] [llvm] r88864 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911151957.nAFJvhR9031581@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:57:43 2009 New Revision: 88864 URL: http://llvm.org/viewvc/llvm-project?rev=88864&view=rev Log: fix a bug handling 'not x' when x is undef. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=88864&r1=88863&r2=88864&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Nov 15 13:57:43 2009 @@ -350,8 +350,9 @@ // Invert the known values. for (unsigned i = 0, e = Result.size(); i != e; ++i) - Result[i].first = - cast(ConstantExpr::getNot(Result[i].first)); + if (Result[i].first) + Result[i].first = + cast(ConstantExpr::getNot(Result[i].first)); return true; } } From sabre at nondot.org Sun Nov 15 13:58:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:58:32 -0000 Subject: [llvm-commits] [llvm] r88865 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911151958.nAFJwWM9031615@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:58:31 2009 New Revision: 88865 URL: http://llvm.org/viewvc/llvm-project?rev=88865&view=rev Log: make PRE of loads preserve the alignment of the moved load instruction. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=88865&r1=88864&r2=88865&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Nov 15 13:58:31 2009 @@ -585,6 +585,8 @@ if (isa(CondCmp->getOperand(1))) SimplifyValue = CondCmp->getOperand(0); + // TODO: There are other places where load PRE would be profitable, such as + // more complex comparisons. if (LoadInst *LI = dyn_cast(SimplifyValue)) if (SimplifyPartiallyRedundantLoad(LI)) return true; @@ -752,7 +754,7 @@ Value *LoadedPtr = LI->getOperand(0); // If the loaded operand is defined in the LoadBB, it can't be available. - // FIXME: Could do PHI translation, that would be fun :) + // TODO: Could do simple PHI translation, that would be fun :) if (Instruction *PtrOp = dyn_cast(LoadedPtr)) if (PtrOp->getParent() == LoadBB) return false; @@ -761,8 +763,8 @@ // the entry to its block. BasicBlock::iterator BBIt = LI; - if (Value *AvailableVal = FindAvailableLoadedValue(LoadedPtr, LoadBB, - BBIt, 6)) { + if (Value *AvailableVal = + FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt, 6)) { // If the value if the load is locally available within the block, just use // it. This frequently occurs for reg2mem'd allocas. //cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n"; @@ -845,7 +847,7 @@ // Split them out to their own block. UnavailablePred = SplitBlockPredecessors(LoadBB, &PredsToSplit[0], PredsToSplit.size(), - "thread-split", this); + "thread-pre-split", this); } // If the value isn't available in all predecessors, then there will be @@ -854,7 +856,8 @@ if (UnavailablePred) { assert(UnavailablePred->getTerminator()->getNumSuccessors() == 1 && "Can't handle critical edge here!"); - Value *NewVal = new LoadInst(LoadedPtr, LI->getName()+".pr", + Value *NewVal = new LoadInst(LoadedPtr, LI->getName()+".pr", false, + LI->getAlignment(), UnavailablePred->getTerminator()); AvailablePreds.push_back(std::make_pair(UnavailablePred, NewVal)); } From sabre at nondot.org Sun Nov 15 13:59:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 15 Nov 2009 19:59:49 -0000 Subject: [llvm-commits] [llvm] r88866 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <200911151959.nAFJxnjG031672@zion.cs.uiuc.edu> Author: lattner Date: Sun Nov 15 13:59:49 2009 New Revision: 88866 URL: http://llvm.org/viewvc/llvm-project?rev=88866&view=rev Log: refactor a bunch of code forming the new LazyValueInfoCache and LVIQuery classes, no functionality change. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=88866&r1=88865&r2=88866&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Sun Nov 15 13:59:49 2009 @@ -195,69 +195,75 @@ } //===----------------------------------------------------------------------===// -// LazyValueInfo Impl +// LazyValueInfoCache Decl //===----------------------------------------------------------------------===// -bool LazyValueInfo::runOnFunction(Function &F) { - TD = getAnalysisIfAvailable(); - // Fully lazy. - return false; -} +namespace { + /// LazyValueInfoCache - This is the cache kept by LazyValueInfo which + /// maintains information about queries across the clients' queries. + class LazyValueInfoCache { + public: + /// BlockCacheEntryTy - This is a computed lattice value at the end of the + /// specified basic block for a Value* that depends on context. + typedef std::pair BlockCacheEntryTy; + + /// ValueCacheEntryTy - This is all of the cached block information for + /// exactly one Value*. The entries are sorted by the BasicBlock* of the + /// entries, allowing us to do a lookup with a binary search. + typedef std::vector ValueCacheEntryTy; + + private: + /// ValueCache - This is all of the cached information for all values, + /// mapped from Value* to key information. + DenseMap ValueCache; + public: + + /// getValueInBlock - This is the query interface to determine the lattice + /// value for the specified Value* at the end of the specified block. + LVILatticeVal getValueInBlock(Value *V, BasicBlock *BB); + + /// getValueOnEdge - This is the query interface to determine the lattice + /// value for the specified Value* that is true on the specified edge. + LVILatticeVal getValueOnEdge(Value *V, BasicBlock *FromBB,BasicBlock *ToBB); + }; +} // end anonymous namespace -void LazyValueInfo::releaseMemory() { - // No caching yet. -} +//===----------------------------------------------------------------------===// +// LVIQuery Impl +//===----------------------------------------------------------------------===// -static LVILatticeVal GetValueInBlock(Value *V, BasicBlock *BB, - DenseMap &); +namespace { + /// LVIQuery - This is a transient object that exists while a query is + /// being performed. + class LVIQuery { + typedef LazyValueInfoCache::BlockCacheEntryTy BlockCacheEntryTy; + typedef LazyValueInfoCache::ValueCacheEntryTy ValueCacheEntryTy; + + /// This is the current value being queried. + Value *Val; + + /// This is all of the cached information about this value. + ValueCacheEntryTy &Cache; + + /// BlockVals Temporary Cache used while processing a query. + DenseMap BlockVals; -static LVILatticeVal GetValueOnEdge(Value *V, BasicBlock *BBFrom, - BasicBlock *BBTo, - DenseMap &BlockVals) { - // FIXME: Pull edge logic out of jump threading. - - - if (BranchInst *BI = dyn_cast(BBFrom->getTerminator())) { - // If this is a conditional branch and only one successor goes to BBTo, then - // we maybe able to infer something from the condition. - if (BI->isConditional() && - BI->getSuccessor(0) != BI->getSuccessor(1)) { - bool isTrueDest = BI->getSuccessor(0) == BBTo; - assert(BI->getSuccessor(!isTrueDest) == BBTo && - "BBTo isn't a successor of BBFrom"); - - // If V is the condition of the branch itself, then we know exactly what - // it is. - if (BI->getCondition() == V) - return LVILatticeVal::get(ConstantInt::get( - Type::getInt1Ty(V->getContext()), isTrueDest)); - - // If the condition of the branch is an equality comparison, we may be - // able to infer the value. - if (ICmpInst *ICI = dyn_cast(BI->getCondition())) - if (ICI->isEquality() && ICI->getOperand(0) == V && - isa(ICI->getOperand(1))) { - // We know that V has the RHS constant if this is a true SETEQ or - // false SETNE. - if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) - return LVILatticeVal::get(cast(ICI->getOperand(1))); - return LVILatticeVal::getNot(cast(ICI->getOperand(1))); - } + public: + + LVIQuery(Value *V, ValueCacheEntryTy &VC) : Val(V), Cache(VC) { } - } - - // TODO: Info from switch. - - - // Otherwise see if the value is known in the block. - return GetValueInBlock(V, BBFrom, BlockVals); -} -static LVILatticeVal GetValueInBlock(Value *V, BasicBlock *BB, - DenseMap &BlockVals) { + LVILatticeVal getBlockValue(BasicBlock *BB); + + LVILatticeVal getEdgeValue(BasicBlock *FromBB, BasicBlock *ToBB); + }; +} // end anonymous namespace + + +LVILatticeVal LVIQuery::getBlockValue(BasicBlock *BB) { // See if we already have a value for this block. LVILatticeVal &BBLV = BlockVals[BB]; - + // If we've already computed this block's value, return it. if (!BBLV.isUndefined()) return BBLV; @@ -266,18 +272,17 @@ // lattice value to overdefined, so that cycles will terminate and be // conservatively correct. BBLV.markOverdefined(); - - LVILatticeVal Result; // Start Undefined. - // If V is live in to BB, see if our predecessors know anything about it. - Instruction *BBI = dyn_cast(V); + // If V is live into BB, see if our predecessors know anything about it. + Instruction *BBI = dyn_cast(Val); if (BBI == 0 || BBI->getParent() != BB) { + LVILatticeVal Result; // Start Undefined. unsigned NumPreds = 0; // Loop over all of our predecessors, merging what we know from them into // result. for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { - Result.mergeIn(GetValueOnEdge(V, *PI, BB, BlockVals)); + Result.mergeIn(getEdgeValue(*PI, BB)); // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. @@ -289,16 +294,16 @@ // If this is the entry block, we must be asking about an argument. The // value is overdefined. if (NumPreds == 0 && BB == &BB->getParent()->front()) { - assert(isa(V) && "Unknown live-in to the entry block"); + assert(isa(Val) && "Unknown live-in to the entry block"); Result.markOverdefined(); return Result; } - + // Return the merged value, which is more precise than 'overdefined'. assert(!Result.isOverdefined()); return BlockVals[BB] = Result; } - + // If this value is defined by an instruction in this block, we have to // process it here somehow or return overdefined. if (PHINode *PN = dyn_cast(BBI)) { @@ -308,24 +313,115 @@ } + LVILatticeVal Result; Result.markOverdefined(); return BlockVals[BB] = Result; } -Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) { - // If already a constant, return it. - if (Constant *VC = dyn_cast(V)) - return VC; +/// getEdgeValue - This method +LVILatticeVal LVIQuery::getEdgeValue(BasicBlock *BBFrom, BasicBlock *BBTo) { + if (BranchInst *BI = dyn_cast(BBFrom->getTerminator())) { + // If this is a conditional branch and only one successor goes to BBTo, then + // we maybe able to infer something from the condition. + if (BI->isConditional() && + BI->getSuccessor(0) != BI->getSuccessor(1)) { + bool isTrueDest = BI->getSuccessor(0) == BBTo; + assert(BI->getSuccessor(!isTrueDest) == BBTo && + "BBTo isn't a successor of BBFrom"); + + // If V is the condition of the branch itself, then we know exactly what + // it is. + if (BI->getCondition() == Val) + return LVILatticeVal::get(ConstantInt::get( + Type::getInt1Ty(Val->getContext()), isTrueDest)); + + // If the condition of the branch is an equality comparison, we may be + // able to infer the value. + if (ICmpInst *ICI = dyn_cast(BI->getCondition())) + if (ICI->isEquality() && ICI->getOperand(0) == Val && + isa(ICI->getOperand(1))) { + // We know that V has the RHS constant if this is a true SETEQ or + // false SETNE. + if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) + return LVILatticeVal::get(cast(ICI->getOperand(1))); + return LVILatticeVal::getNot(cast(ICI->getOperand(1))); + } + } + } - DenseMap BlockValues; + // TODO: Info from switch. + + // TODO: Handle more complex conditionals. If (v == 0 || v2 < 1) is false, we + // know that v != 0. + + // Otherwise see if the value is known in the block. + return getBlockValue(BBFrom); +} + + +//===----------------------------------------------------------------------===// +// LazyValueInfoCache Impl +//===----------------------------------------------------------------------===// + +LVILatticeVal LazyValueInfoCache::getValueInBlock(Value *V, BasicBlock *BB) { + // If already a constant, there is nothing to compute. + if (Constant *VC = dyn_cast(V)) + return LVILatticeVal::get(VC); DEBUG(errs() << "Getting value " << *V << " at end of block '" - << BB->getName() << "'\n"); - LVILatticeVal Result = GetValueInBlock(V, BB, BlockValues); + << BB->getName() << "'\n"); + + LVILatticeVal Result = LVIQuery(V, ValueCache[V]).getBlockValue(BB); DEBUG(errs()