[llvm-commits] [llvm] r71688 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Dale Johannesen dalej at apple.com
Wed May 13 12:03:24 PDT 2009


On May 13, 2009, at 11:29 AMPDT, Chris Lattner wrote:

>
> On May 13, 2009, at 11:25 AM, Dale Johannesen wrote:
>
>> Author: johannes
>> Date: Wed May 13 13:25:07 2009
>> New Revision: 71688
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=71688&view=rev
>> Log:
>> Don't generate a select whose operand is load of a weak
>> external.  These may have address 0 and are not safe
>> to execute unconditionally.
>
> Hi Dale,
>
> Thanks for working on this, but I don't think that this is  
> sufficient: it will fail for getelementptr constant exprs of a weak  
> global.  I think this should probably use something like  
> isSafeToLoadUnconditionally in instcombine.  Maybe that function  
> should move to transforms/utils.

The previous test

>>        if (!isa<AllocaInst>(I->getOperand(0)) &&
>>            !isa<Constant>(I->getOperand(0)))
>>          return false;

will reject GEP's won't it?

> Also, testcase? :)

Done.

> -Chris
>
>>
>>
>>
>> Modified:
>>   llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=71688&r1=71687&r2=71688&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed May 13  
>> 13:25:07 2009
>> @@ -18,6 +18,7 @@
>> #include "llvm/IntrinsicInst.h"
>> #include "llvm/Type.h"
>> #include "llvm/DerivedTypes.h"
>> +#include "llvm/GlobalVariable.h"
>> #include "llvm/Support/CFG.h"
>> #include "llvm/Support/Debug.h"
>> #include "llvm/Analysis/ConstantFolding.h"
>> @@ -393,6 +394,11 @@
>>        if (!isa<AllocaInst>(I->getOperand(0)) &&
>>            !isa<Constant>(I->getOperand(0)))
>>          return false;
>> +        // External weak globals may have address 0, so we can't  
>> load them.
>> +        if (GlobalVariable* GV= dyn_cast<GlobalVariable>(I- 
>> >getOperand(0))) {
>> +          if (GV->hasExternalWeakLinkage())
>> +            return false;
>> +        }
>>
>>        // Finally, we have to check to make sure there are no  
>> instructions
>>        // before the load in its basic block, as we are going to  
>> hoist the loop
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list