|
38 | 38 | #include "llvm/IR/MDBuilder.h" |
39 | 39 | #include "llvm/IR/MemoryModelRelaxationAnnotations.h" |
40 | 40 | #include "llvm/IR/Module.h" |
| 41 | +#include "llvm/IR/ProfDataUtils.h" |
41 | 42 | #include "llvm/IR/Type.h" |
42 | 43 | #include "llvm/IR/User.h" |
43 | 44 | #include "llvm/IR/Value.h" |
@@ -1259,8 +1260,7 @@ Value *AtomicExpandImpl::insertRMWLLSCLoop( |
1259 | 1260 | BasicBlock *BB = Builder.GetInsertBlock(); |
1260 | 1261 | Function *F = BB->getParent(); |
1261 | 1262 |
|
1262 | | - assert(AddrAlign >= |
1263 | | - F->getDataLayout().getTypeStoreSize(ResultTy) && |
| 1263 | + assert(AddrAlign >= F->getDataLayout().getTypeStoreSize(ResultTy) && |
1264 | 1264 | "Expected at least natural alignment at this point."); |
1265 | 1265 |
|
1266 | 1266 | // Given: atomicrmw some_op iN* %addr, iN %incr ordering |
@@ -1680,7 +1680,12 @@ Value *AtomicExpandImpl::insertRMWCmpXchgLoop( |
1680 | 1680 |
|
1681 | 1681 | Loaded->addIncoming(NewLoaded, LoopBB); |
1682 | 1682 |
|
1683 | | - Builder.CreateCondBr(Success, ExitBB, LoopBB); |
| 1683 | + Instruction *CondBr = Builder.CreateCondBr(Success, ExitBB, LoopBB); |
| 1684 | + |
| 1685 | + // Atomic RMW expands to a cmpxchg loop, Since precise branch weights |
| 1686 | + // cannot be easily determined here, we mark the branch as "unknown" (50/50) |
| 1687 | + // to prevent misleading optimizations. |
| 1688 | + setExplicitlyUnknownBranchWeightsIfProfiled(*CondBr, *F, DEBUG_TYPE); |
1684 | 1689 |
|
1685 | 1690 | Builder.SetInsertPoint(ExitBB, ExitBB->begin()); |
1686 | 1691 | return NewLoaded; |
|
0 commit comments