Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 728b46a

Browse files
committed
Revert some fastcomp changes
1 parent 5fbe4e6 commit 728b46a

File tree

3 files changed

+4
-70
lines changed

3 files changed

+4
-70
lines changed

lib/IR/Verifier.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,10 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
606606
GV.hasAvailableExternallyLinkage(),
607607
"Global is marked as dllimport, but not external", &GV);
608608

609-
//if (!GV.hasInitializer()) { // XXX EMSCRIPTEN - do not do extra verification below, 40x slower linking on some big projects
609+
if (!GV.hasInitializer()) {
610610
visitGlobalValue(GV);
611611
return;
612-
//}
612+
}
613613

614614
// Walk any aggregate initializers looking for bitcasts between address spaces
615615
visitConstantExprsRecursively(GV.getInitializer());

lib/Transforms/IPO/GlobalOpt.cpp

+1-57
Original file line numberDiff line numberDiff line change
@@ -1547,61 +1547,6 @@ static bool optimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
15471547
return false;
15481548
}
15491549

1550-
/// TryToAddRangeMetadata - At this point, we have learned that the only
1551-
/// two values ever stored into GV are its initializer and OtherVal. See if we
1552-
/// can annotate loads from it with range metadata describing this.
1553-
/// This exposes the values to other scalar optimizations.
1554-
static bool TryToAddRangeMetadata(GlobalVariable *GV, Constant *OtherVal) {
1555-
Type *GVElType = GV->getType()->getElementType();
1556-
1557-
// If GVElType is already i1, it already has a minimal range. If the type of
1558-
// the GV is an FP value, pointer or vector, don't do this optimization
1559-
// because range metadata is currently only supported on scalar integers.
1560-
if (GVElType == Type::getInt1Ty(GV->getContext()) ||
1561-
GVElType->isFloatingPointTy() ||
1562-
GVElType->isPointerTy() || GVElType->isVectorTy())
1563-
return false;
1564-
1565-
// Walk the use list of the global seeing if all the uses are load or store.
1566-
// If there is anything else, bail out.
1567-
for (User *U : GV->users())
1568-
if (!isa<LoadInst>(U) && !isa<StoreInst>(U))
1569-
return false;
1570-
1571-
Constant *InitVal = GV->getInitializer();
1572-
assert(InitVal->getType() != Type::getInt1Ty(GV->getContext()) &&
1573-
"No reason to add range metadata!");
1574-
1575-
// The MD_range metadata only supports absolute integer constants.
1576-
if (!isa<ConstantInt>(InitVal) || !isa<ConstantInt>(OtherVal))
1577-
return false;
1578-
1579-
DEBUG(dbgs() << " *** ADDING RANGE METADATA: " << *GV);
1580-
1581-
for (Value::user_iterator I = GV->user_begin(), E = GV->user_end(); I != E; ++I){
1582-
Instruction *UI = cast<Instruction>(*I);
1583-
if (LoadInst *LI = dyn_cast<LoadInst>(UI)) {
1584-
// If we already have a range, don't add a new one, so that GlobalOpt
1585-
// terminates. In theory, we could merge the two ranges.
1586-
if (LI->getMetadata(LLVMContext::MD_range))
1587-
return false;
1588-
// Add range metadata to the load. We have two possible values, and we
1589-
// need to create a half-open range. The range can wrap, so we can use
1590-
// either signed or unsigned; we pick signed because it might be prettier
1591-
// in common cases.
1592-
Constant *Cmp = ConstantExpr::getICmp(ICmpInst::ICMP_SLT, InitVal, OtherVal);
1593-
Constant *One = ConstantInt::get(LI->getType(), 1);
1594-
SmallVector<Metadata *, 2> NewOps;
1595-
NewOps.push_back(ConstantAsMetadata::get(ConstantExpr::getSelect(Cmp, InitVal, OtherVal)));
1596-
NewOps.push_back(ConstantAsMetadata::get(ConstantExpr::getAdd(ConstantExpr::getSelect(Cmp, OtherVal, InitVal), One)));
1597-
MDNode *MD = MDNode::get(LI->getContext(), NewOps);
1598-
LI->setMetadata(LLVMContext::MD_range, MD);
1599-
}
1600-
}
1601-
1602-
return true;
1603-
}
1604-
16051550
/// At this point, we have learned that the only two values ever stored into GV
16061551
/// are its initializer and OtherVal. See if we can shrink the global into a
16071552
/// boolean and select between the two values whenever it is used. This exposes
@@ -1981,10 +1926,9 @@ static bool processInternalGlobal(
19811926

19821927
// Otherwise, if the global was not a boolean, we can shrink it to be a
19831928
// boolean.
1984-
// XXX EMSCRIPTEN - add range metadata instead
19851929
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue)) {
19861930
if (GS.Ordering == AtomicOrdering::NotAtomic) {
1987-
if (TryToAddRangeMetadata(GV, SOVConstant)) { // XXX EMSCRIPTEN
1931+
if (TryToShrinkGlobalToBoolean(GV, SOVConstant)) {
19881932
++NumShrunkToBool;
19891933
return true;
19901934
}

lib/Transforms/InstCombine/InstCombineVectorOps.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -1249,17 +1249,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
12491249

12501250
// If the result mask is equal to one of the original shuffle masks,
12511251
// or is a splat, do the replacement.
1252-
//
1253-
// XXX EMSCRIPTEN: Add '|| true' so that we always do the replacement.
1254-
// We're targetting SIMD.js, so there's less of an expectation that a
1255-
// particular shuffle mask will always map onto a particular instruction on
1256-
// a particular ISA because we aren't targetting a particular ISA (what the
1257-
// JS engine does is another story). We may wish to re-evaluate this choice
1258-
// as we move on to higher-element-count vectors, but especially for now this
1259-
// is quite desirable.
1260-
if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask ||
1261-
true)
1262-
{
1252+
if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask) {
12631253
SmallVector<Constant*, 16> Elts;
12641254
for (unsigned i = 0, e = newMask.size(); i != e; ++i) {
12651255
if (newMask[i] < 0) {

0 commit comments

Comments
 (0)