Revert "[MS] Overhaul how clang passes overaligned args on x86_32"
It broke some Chromium tests, so let's revert until it can be fixed; see
https://crbug.com/1046362
This reverts commit 2af74e27ed7d0832cbdde9cb969aaca7a42e99f9.
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 5b03f37..3a50e2b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2339,9 +2339,6 @@
auto FieldIndex = ArgI.getInAllocaFieldIndex();
Address V =
Builder.CreateStructGEP(ArgStruct, FieldIndex, Arg->getName());
- if (ArgI.getInAllocaIndirect())
- V = Address(Builder.CreateLoad(V),
- getContext().getTypeAlignInChars(Ty));
ArgVals.push_back(ParamValue::forIndirect(V));
break;
}
@@ -4041,39 +4038,18 @@
assert(NumIRArgs == 0);
assert(getTarget().getTriple().getArch() == llvm::Triple::x86);
if (I->isAggregate()) {
+ // Replace the placeholder with the appropriate argument slot GEP.
Address Addr = I->hasLValue()
? I->getKnownLValue().getAddress(*this)
: I->getKnownRValue().getAggregateAddress();
llvm::Instruction *Placeholder =
cast<llvm::Instruction>(Addr.getPointer());
-
- if (!ArgInfo.getInAllocaIndirect()) {
- // Replace the placeholder with the appropriate argument slot GEP.
- CGBuilderTy::InsertPoint IP = Builder.saveIP();
- Builder.SetInsertPoint(Placeholder);
- Addr = Builder.CreateStructGEP(ArgMemory,
- ArgInfo.getInAllocaFieldIndex());
- Builder.restoreIP(IP);
- } else {
- // For indirect things such as overaligned structs, replace the
- // placeholder with a regular aggregate temporary alloca. Store the
- // address of this alloca into the struct.
- Addr = CreateMemTemp(info_it->type, "inalloca.indirect.tmp");
- Address ArgSlot = Builder.CreateStructGEP(
- ArgMemory, ArgInfo.getInAllocaFieldIndex());
- Builder.CreateStore(Addr.getPointer(), ArgSlot);
- }
- deferPlaceholderReplacement(Placeholder, Addr.getPointer());
- } else if (ArgInfo.getInAllocaIndirect()) {
- // Make a temporary alloca and store the address of it into the argument
- // struct.
- Address Addr = CreateMemTempWithoutCast(
- I->Ty, getContext().getTypeAlignInChars(I->Ty),
- "indirect-arg-temp");
- I->copyInto(*this, Addr);
- Address ArgSlot =
+ CGBuilderTy::InsertPoint IP = Builder.saveIP();
+ Builder.SetInsertPoint(Placeholder);
+ Addr =
Builder.CreateStructGEP(ArgMemory, ArgInfo.getInAllocaFieldIndex());
- Builder.CreateStore(Addr.getPointer(), ArgSlot);
+ Builder.restoreIP(IP);
+ deferPlaceholderReplacement(Placeholder, Addr.getPointer());
} else {
// Store the RValue into the argument struct.
Address Addr =