[LoongArch] Reorder code and inline variable in lowerGlobalTLSAddress for clarity...
authorwanglei <wanglei@loongson.cn>
Sat, 7 Jan 2023 07:22:47 +0000 (15:22 +0800)
committerwanglei <wanglei@loongson.cn>
Sat, 7 Jan 2023 07:26:39 +0000 (15:26 +0800)
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

index b5e5374..afdc6d1 100644 (file)
@@ -550,17 +550,15 @@ SDValue LoongArchTargetLowering::getDynamicTLSAddr(GlobalAddressSDNode *N,
 SDValue
 LoongArchTargetLowering::lowerGlobalTLSAddress(SDValue Op,
                                                SelectionDAG &DAG) const {
-  GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
-  assert(N->getOffset() == 0 && "unexpected offset in global node");
-
-  SDValue Addr;
-  TLSModel::Model Model = getTargetMachine().getTLSModel(N->getGlobal());
-
   if (DAG.getMachineFunction().getFunction().getCallingConv() ==
       CallingConv::GHC)
     report_fatal_error("In GHC calling convention TLS is not supported");
 
-  switch (Model) {
+  GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
+  assert(N->getOffset() == 0 && "unexpected offset in global node");
+
+  SDValue Addr;
+  switch (getTargetMachine().getTLSModel(N->getGlobal())) {
   case TLSModel::GeneralDynamic:
     // In this model, application code calls the dynamic linker function
     // __tls_get_addr to locate TLS offsets into the dynamic thread vector at