================
@@ -5590,28 +5600,29 @@ class CodeGenFunction : public CodeGenTypeCache {
inline DominatingLLVMValue::saved_type
DominatingLLVMValue::save(CodeGenFunction &CGF, llvm::Value *value) {
if (!needsSaving(value))
- return saved_type(value, false);
+ return saved_type(value);
// Otherwise, we need an alloca.
auto align = CharUnits::fromQuantity(
- CGF.CGM.getDataLayout().getPrefTypeAlign(value->getType()));
- Address alloca =
- CGF.CreateTempAlloca(value->getType(), align, "cond-cleanup.save");
- CGF.Builder.CreateStore(value, alloca);
-
- return saved_type(alloca.emitRawPointer(CGF), true);
+ CGF.CGM.getDataLayout().getPrefTypeAlign(value->getType()))
+ .getAsAlign();
+ llvm::AllocaInst *AI =
+ CGF.CreateTempAlloca(value->getType(), "cond-cleanup.save");
+ AI->setAlignment(align);
+ CGF.Builder.CreateAlignedStore(value, AI, align);
+
+ return saved_type(AI, value->getType());
}
inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
saved_type value) {
// If the value says it wasn't saved, trust that it's still dominating.
- if (!value.getInt())
- return value.getPointer();
+ if (!value.isSaved())
+ return value.Value;
// Otherwise, it should be an alloca instruction, as set up in save().
- auto alloca = cast<llvm::AllocaInst>(value.getPointer());
- return CGF.Builder.CreateAlignedLoad(alloca->getAllocatedType(), alloca,
- alloca->getAlign());
+ auto AI = cast<llvm::AllocaInst>(value.Value);
----------------
ojhunt wrote:
I know there's a lot of things like `AllocaInst *AI =`, `RecordDecl *RD`,
naming but I think sticking to `Alloca` here but correcting the capitalization
is better.
https://github.com/llvm/llvm-project/pull/181740
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits